开发者

Will Java's garbage collector interrupt a thread?

Something is interrupting threads in my application. It appears to happen when the JVM is close to running out of heap space. I can configure additional heap for the JVM but I'm curious if the garbage collector is interrupting threads in an attempt to reclaim开发者_Go百科 memory. Does anyone know? I am using the 64 bit Java 1.6.0_16 on RedHat ES 5.2.

Thanks,

John


Interrupt as in throw InterruptedException? No, that shouldn't happen. It may need to pause the thread itself, but that's not the same thing. If the VM runs out of memory completely, it should throw OutOfMemoryError instead...


Unless OutOfMemory happens, Threads will not be interrupted if garbage collection happens. They may go in wait state for sometime.


You may be receiving so-called spurious interrupts. They may happen at any time but a low-memory / high-load situation may be making them more likely. However, this will depend on JVM implementation details, it's not a rule and the correlation with garbage collection (if there actually is any) is incidental and not by design.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜