YaK:: Smilax : Interrupting Java Threads [Changes]   [Calendar]   [Search]   [Index]   [PhotoTags]   
[mega_changes]
[photos]

Smilax: Interrupting Java Threads

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:
    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.
    
  • 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?

  • (unless otherwise marked) Copyright 2002-2014 YakPeople. All rights reserved.
    (last modified 2003-03-27)       [Login]
    (No back references.)