title {Smilax: Interrupting Java Threads} vol 1 user strick ip 147.144.66.161 lock ******** Smilax needs to be able to stop all threads and shut itself down. This is our approach: * Inp and Outp will poll a ````j_stopPlease'''' bit in BaseJob, which all jobs (threads) in Smilax inherit from. This will allow interrupting work which is reading and writing files. * BaseJob has a ````j_socket'''' field. If the thread reads and writes a socket, it can set this field. We will close the socket, forcing a blocking read or write to finish. Source: http://java.sun.com/j2se/1.4/docs/guide/misc/threadPrimitiveDeprecation.html: /pre( What if a thread doesn't respond to Thread.interrupt? In some cases, you can use application specific tricks. For example, if a thread is waiting on a known socket, you can close the socket to cause the thread to return immediately. Unfortunately, there really isn't any technique that works in general. It should be noted that in all situations where a waiting thread doesn't respond to Thread.interrupt, it wouldn't respond to Thread.stop either. Such cases include deliberate denial-of-service attacks, and I/O operations for which thread.stop and thread.interrupt do not work properly. /pre) * BaseJob has a ````j_queue'''' field. We will put an ````Err'''' object on the queue. (But actually it will be calling wait(), and interrupt() should kill it.) * Infinite loops are still a problem. We might try the depricated Thread.stop() as a last resort? 0ops, the above quote kinda says that wont work either. OK, just exit() the process