This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread Safe Collection classes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread Safe Collection classes?" Watch "Thread Safe Collection classes?" New topic
Author

Thread Safe Collection classes?

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9353
    
    2

Guys,

Can anyone tell me which classes in the Collection interface are thread safe?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Sanjeev Singh
Ranch Hand

Joined: Nov 01, 2006
Posts: 381
Jothi,
Hashtable and Vector has the methods which are syncronized and are thread safe.
Syncronized collections can be made through the utility methods in Collections class from the existing collection.


~Sanjeev Singh<br />SCJP 1.5
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9353
    
    2

Thanks Sanjeev. By the way, what it means "Syncronized collections can be made through the utility methods in Collections class from the existing collection."??
Sanjeev Singh
Ranch Hand

Joined: Nov 01, 2006
Posts: 381
Please look into the Collections utility class.
It has six syncronizedXxxx()methods which returns a syncronized collection.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9353
    
    2

Allright, I'll get back to this tonight after I finish perusing through Collections class.
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Hi Jothi,

there are methods in java.util.Collections that return a thread safe collection from a non thread safe one.
All these methods names start with "synchronized".
e.g.
List<Double> list = new ArrayList<Double>();
List<Double> safe;
safe = Collections.synchronizedList(list);


Yours,
Bu.


all events occur in real time
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread Safe Collection classes?