I want to interrupt running thread while something slow responding.
This post described exactly the problem:
How to handle java.lang.Thread.interrupt() in a safe way?
We using the only one code below keeping _selector pipe never broken.
Since we indicate interrupt the current thread, throwing exceptions are very acceptable.
Will you please review this code, if it works, please commit it into next release.Code:public void setInterrupt() { if(++_interruptCount == 1) { java.nio.ByteBuffer buf = java.nio.ByteBuffer.allocate(1); buf.put(0, (byte)0); while(buf.hasRemaining()) { try { Thread.interrupted(); _fdIntrWrite.write(buf); } catch(java.io.IOException ex) { Ice.SocketException se = new Ice.SocketException(); se.initCause(ex); throw se; } } } }

Reply With Quote