博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
例13_1 本例用于演示线程终止
阅读量:4509 次
发布时间:2019-06-08

本文共 508 字,大约阅读时间需要 1 分钟。

// 本例用于演示线程终止

class E13_1

{
public static void main(String args[])
{
A a=new A();
Thread thread=new Thread(a);
thread.setName("zhang san");
thread.start();

}

}

class A implements Runnable

{
int number=0;
boolean stop=false;
boolean getStop()
{
return stop;
}
public void run()
{
while(!stop)
{
number++;
System.out.println(Thread.currentThread().getName()+"的number="+number);
if(number==3){
stop=true;
}
try{ Thread.sleep(1000);}
catch(Exception e){}
}
}
}

转载于:https://www.cnblogs.com/sxdxjava/p/5500779.html

你可能感兴趣的文章
静态网页中的使得文字向上一直滚动,中间不间断。
查看>>
MySQL常见错误代码说明
查看>>
innobackupex 相关语法讲解【转】
查看>>
pt-table-sync同步报错Called not_in_left in state 0 at /usr/bin/pt-table-sync line 5231【原创】...
查看>>
jooq使用示例
查看>>
属性参数
查看>>
AQS独占式同步队列入队与出队
查看>>
修改原代码定制bootstrap
查看>>
idea快捷键
查看>>
shell——bash在线编辑
查看>>
Kth Smallest Element in a BST
查看>>
iOS开发从新手到App Store上架
查看>>
poj--2516--Minimum Cost(最小费用流)
查看>>
ZXV10 H608B V1.1.04T02_JS破解
查看>>
数据可视化是什么
查看>>
强连通分量
查看>>
WinForm应用程序之注册模块的设计与实现
查看>>
spark-Streaming
查看>>
UVa1252
查看>>
[SCOI2014]方伯伯的玉米田 题解(树状数组优化dp)
查看>>