这是对Java中常见并发问题的一种调查.一个例子可能是经典的死锁或竞争条件,或者可能是Swing中的EDT线程错误.我对各种可能的问题既感兴趣,也对最常见的问题感兴趣.因此,请在每条评论中留下Java并发错误的一个特定答案,如果您看到自己遇到的错误,请立即投票.
Thread currentThread=Thread.currentThread();
public void run()
{
while(!shutdown)
{
try
{
System.out.println(currentThread.isAlive());
Thread.interrupted();
System.out.println(currentThread.isAlive());
if(currentThread.isAlive()==false)
{
shutdown=true;
}
}
catch(Exception e)
{
currentThread.interrupt();
}
}
}
});
thread.start();
Run Code Online (Sandbox Code Playgroud)