How should I handle InterruptedExceptionwhen connecting to other threads, assuming that I actually do not expect an interruption, and there is no reasonable thing? Just swallow the exception?
try
{
t.join();
u.join();
}
catch (InterruptedException e)
{
}
Or should I put each one joinseparately try/catch, so if it InterruptedExeptionhappens when connecting t, at least it ugets a chance to join?
try
{
t.join();
}
catch (InterruptedException e)
{
}
try
{
u.join();
}
catch (InterruptedException e)
{
}
Or should I defend exceptions in the loop, so am I finally joining both threads, even if some kind of evil guy is trying to interrupt me?
while (true)
{
try
{
t.join();
break;
}
catch (InterruptedException e)
{
}
}
while (true)
{
try
{
u.join();
break;
}
catch (InterruptedException e)
{
}
}
On the side of the note, is there a case where InterruptedExeptionit doesn't make my code look ugly? :)
source
share