Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know the cause of InterruptedException in Java

How to know the thread A that interrupted the thread B that is throwing the InterruptedException?

like image 896
Jason Bourne Avatar asked Nov 09 '22 19:11

Jason Bourne


1 Answers

No, you could not know which thread triggers the interrupt.

It is kind of status flag, that's it. No matter InterruptedException or isInterrupted(), there is no extra information provided.

Further, if you need to cooperate threads in finer grade, try other ways.

like image 135
卢声远 Shengyuan Lu Avatar answered Nov 14 '22 21:11

卢声远 Shengyuan Lu