The concept of a thread joining itself does not make sense.
It happens out that the
In other words, the
join()
method uses the isAlive()
method to determine when to return from thejoin()
method. In the current implementation, it also does not check to see if the thread is joining itself.In other words, the
join()
method returns when and only when the thread is no longer alive. This will have the effect of waiting forever.I saw this in Helix:
public void run()
{
LockProcess lockProcess = null;
try
{
lockProcess = new LockProcess(clusterName, ZK_ADDRESS,
instanceName, startController);
lockProcess.start();
Thread.currentThread().join();
} catch (InterruptedException e)
{
System.out.println(instanceName + "Interrupted");
if (lockProcess != null)
{
lockProcess.stop();
}
} catch (Exception e)
{
e.printStackTrace();
}
}
No comments:
Post a Comment