[concurrency-interest] Questions on ConcurrentHashMap

Gregg Wonderly gergg at cox.net
Fri Nov 30 16:56:51 EST 2007


Gregg Wonderly wrote:
> Tim Peierls wrote:
> 
>>Sorry if this is obvious to everyone else, but I don't understand the 
>>interrupt handling in the while loop. How does it terminate?
> 
> 
> On Windows xp SP2 with JDK 1.6, the following does run to completion.  The 
> Thread.interrupt() does seem to raise some type of exceptional processing that 
> the throws clause does not express...

> 		final LazyLoadedReference<Integer> r = new LazyLoadedReference<Integer>() {
> 			protected Integer create() {
> 				log.info("create called");
> 				synchronized( this ) {
> 					try {
> 						this.wait();
> 					} catch (InterruptedException ex) {
> 						log.log( Level.SEVERE, ex.toString()+": wait was interrupted", ex );
> 					}
> 				}
> 				return new Integer( 42 );
> 			}
> 		};

And of course I found my own bug here which causes it to return a value which 
keeps the interruption from propagating up...

It does in fact go into an infinite loop if you do 
Thread.currentThread().interrupt() where my log statement is above.

Gregg Wonderly


More information about the Concurrency-interest mailing list