If you do need to create a thread-safe version of a collection (List, Map or
Set) you can use a number of methods on the java.util.Collections class of
the form:
synchronizedXXX()
such as synchronizedMap(Map m) or synchronizedSet(Set s).
It basically wraps the passed collection with a thread-safe wrapper.
However, you still need to be careful when using an iterator over that
thread-safe collection to ensure that the data doesn't change from under you
while you are iterating. Good examples of how to do this can be found in
the JavaDoc for the Collections class mentioned above.
- kristian
-----Original Message-----
From: Christopher B. Hamlin [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 13, 2002 10:40 AM
To: JRun-Talk
Subject: Re: Do application variables need locking?
> java.util.Hashtable is also synchronized. So if you need synchronized
>access, you can just use that class. If you want to roll your own locking
>better to look at the Collections classes that are by default
>unsynchronized, leaving the decision up to you (I think it is easy to get
>synchronized copies too).
- Chris Hamlin
______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists