2011/1/21 maxxe...@gmail.com <maxxe...@gmail.com>: > In TC6 catalina core, ContainerBase class defines this field to stop > the background processor thread: > > private boolean threadDone = false; > > Shouldn't it be a volatile? Because the background processor refers to > a classloader, could it prevent a (weak) classloader from being gc'ed? >
Reading Chapter 17 of JLS 3rd edition, that defines the current (aka "new") memory model [1], Ch. 17.9 "Sleep and Yield" explicitly mentions that sleep does not have "any synchronization semantics", but interrupt() has synchronization semantics per Ch.17.4.4. I think that using interrupt() is the reason why no issue have been observed here and why "volatile" is not necessary. (Though I wouldn't object if "volatile" were added to that field.) [1] http://java.sun.com/docs/books/jls/third_edition/html/memory.html Best regards, Konstantin Kolinko --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org