3 回答
TA贡献1797条经验 获得超6个赞
class MyThread extends Thread{
public void run()
{
while (!Thread.currentThread().isInterrupted())
{
doFirstPartOfIncrement();
try {
Thread.sleep(10000L);
} catch (InterruptedException e) {
// restore interrupt flag
Thread.currentThread().interrupt();
}
doSecondPartOfIncrement();
}
}}下面是一个类似问题的答案,包括示例代码。
TA贡献1853条经验 获得超6个赞
returnrun
while (!isInterrupted()) {
// doStuff}添加回答
举报
