线程暂停加入主线程临时暂停
Thread t1
= new Thread(){...};
t1
.start
;
try{
t1
.sleep(1000);
t1
.join
;
t1
.yield
;
}catch(){
}
设置线程优先级
Thread t1
= new Thread(){...};
Thread t2
= new Thread(){...};
t1
.setPriority(Thread
.MAX_PRIORITY
);
t2
.setPriority(THread
.MIN_PRIORITY
);
t1
.start
;
t2
.start
;
守护线程:当一个进程里,所有的线程都是守护线程的时候,结束当前线程。
Thread t1
= new Thread(){...};
t1
.setDaemon(true);
t1
.start
;
转载请注明原文地址:https://tech.qufami.com/read-9090.html