View Single Post
  #2 (permalink)  
Old October 9th, 2006, 08:32 PM
panacea panacea is offline
Friend of Wrox
 
Join Date: Jan 2006
Location: San Francisco, CA, USA.
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It looks like you've already passed the info HashMap to the new thread, so therefore the parent thread and the child thread should both have access to it. However, HashMaps are not thread-safe. Therefore you should have a synchronized() block around any code that does gets or sets on the HashMap.

E.g.:

synchronized(info)
{
    info.put("Foo", new Boolean(true));
}

synchronized(info)
{
    boolean foo = ((Boolean)info.get("Foo")).booleanValue();
}


Jon Emerson
http://www.jonemerson.net/
Reply With Quote