wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes synchronized collection wrapper classes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "synchronized collection wrapper classes?" Watch "synchronized collection wrapper classes?" New topic
Author

synchronized collection wrapper classes?

Pal Sudarshan
Ranch Hand

Joined: Jun 10, 2004
Posts: 52
As I have read, Collection classes are not synchronized. Therefore, using them in multithreaded programs may cause errors. That is the reason Sun designed syncrhonization wrappers for the Collections. I don't understand why there is a need for synchronized wrapper classes because don't programmers usually use data strucutres within methods, and if programmers make their methods synchronized, then there is no need for wrapper classes. My question, therefore is, why are there Collection wrapper classes?
Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
It is not necessary to synchronize an entire method in a class you are writing just to have threadsafe access to a Collection. That is why there are Collections that have synchronized methods.
siva raju
Ranch Hand

Joined: Oct 10, 2003
Posts: 37
As i understand it, first we had synch. classes like vector and Hashtable. Because of performance issues, they later provided non-synch. collections like ArrayList and HashMap.


Siva<br />-----<br />SCWCD 1.4, SCJP 1.4, SCBCD(Preparing), CCNA
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: synchronized collection wrapper classes?
 
Similar Threads
quick help, exam tomm, getXXX()
which Collection Class is synchronied?
What is synchronizedCollection(..)..
Differentiate ArrayList and Vector
URLyBIRD: My locking ideas