This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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


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: 9952
    
    3

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: 9952
    
    3

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: 9952
    
    3

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Thread Safe Collection classes?
 
It's not a secret anymore!