攀岩运动,肉浦团 在线观看,雄安不建高楼大厦
下面给出了一个join和interrupt互动的例子,还是主线程要join子线程。
例:1.5.3_1-
class threadmark_to_win extends thread {
thread maint;
int e;
public void run() {
for (int i = 0; i < 10; i++)
{
try {
thread.sleep(100);
} catch (interruptedexception e1) {
e1.printstacktrace();
}
if(i==4) maint.interrupt();
e = e + i;
}
system.out.println("完成"+"e 在子线程"+e);
}
public void setmainthread(thread t1) {
maint=t1;
}
}
public class test {
public static void main(string[] args) {
thread maint = thread.currentthread();
threadmark_to_win tm = new threadmark_to_win();
tm.setmainthread(maint);
tm.start();
try {
tm.join();
} catch (interruptedexception e) {
system.out.println("我是主程序, 也被打断");
。。。。。。。。。。。。。。。。。
详情请进:
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
浅析我对 String、StringBuilder、StringBuffer 的理解
使用IDEA搭建SSM框架的详细教程(spring + springMVC +MyBatis)
Springboot整合freemarker 404问题解决方案
引入mybatis-plus报 Invalid bound statement错误问题的解决方法
网友评论