0

I am in a situation where I catch anInterruptedException but I put a breakpoint at the beginning of the Thread.interrupt() method and there is no hit.

What else can cause InterruptedException to be thrown? Note that I encounter this problem only on Windows, the same code runs fine on Linux. As the interrupt method delegates to a native call interrupt0, I guess it comes from there. But how can I investigate further ?

Thanks

EDIT:

I found my problem. It was also my misunderstanding of the interrupt mechanism. Thread.interrupt is called indeed. What bit me is that it is called long before I start the wait(). But as the thread has the interrupt flag activated, the first call to wait throws the exception immediately.

In my case, it was log4j who set the interrupted flag when it tries to create a NonBlockingSocketAppender on an invalid address. Even weird is that it interrupts the thread it is currently running on...

PeeWee2201
  • 1,464
  • 2
  • 15
  • 23
  • 2
    show your code...so we can better help you.... – grepit Jun 13 '13 at 15:23
  • 2
    Some good info: http://stackoverflow.com/questions/2126997/who-is-calling-the-java-thread-interrupt-method-if-im-not – Gray Jun 13 '13 at 15:24
  • You sure it is throwing `InterruptedException`? – Gray Jun 13 '13 at 15:24
  • 2
    what shows up in the stacktrace for the InterruptedException? – Nathan Hughes Jun 13 '13 at 15:28
  • @CPU100 Well I have 100k lines of code including Spring framework and other thirdparty libraries so I don't know what to show... – PeeWee2201 Jun 13 '13 at 19:18
  • @NathanHughes The stack trace only shows the thread that has been interrupted, no details of what caused the exception... – PeeWee2201 Jun 13 '13 at 19:19
  • @Gray Thanks for the link. I did not find it in my search. It is throwing an InterruptedException. That's the only type of my catch block – PeeWee2201 Jun 13 '13 at 19:26
  • A possible issue is that the debugger is not able to put a breakpoint in the thread interrupt code. So although someone is calling `thread.interrupt()` the debugger is missing it. – Gray Jun 14 '13 at 18:36

0 Answers0