| Author |
synchronized method or block vs vector
|
ajay verma
Ranch Hand
Joined: Dec 10, 2007
Posts: 37
|
|
if i apply the method level synchronization or block level synchronization with any of the legacy class objects like(vector,dictionary,properties,hashtable)! will the thread will behave same as it is behaving with others,means(it will also treat as a normal class object)1 reply asap thank you
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16692
|
|
Most of the classes that you listed are already synchronized -- what do you have in mind? Do you want to synchronized it with another lock? To answer your question, how those classes' behavior changes depends on what you change. Kinda obvious, if you change something, something will change -- maybe if you give us some context on what you are intending to do. Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
amitt jainn
Greenhorn
Joined: Jan 21, 2008
Posts: 4
|
|
Ajay ! In your case when you have a synchronized method and within that you are using historic collection (which are impliclitly synchronized) then it will be the suitable senario for reentrant synchronization Since a thread cannot acquire a lock owned by another thread. But a thread can acquire a lock that it already owns. Allowing a thread to acquire the same lock more than once enables reentrant synchronization. This describes a situation where synchronized code, directly or indirectly, invokes a method that also contains synchronized code, and both sets of code use the same lock. Regards AMIT JAIN
|
 |
 |
|
|
subject: synchronized method or block vs vector
|
|
|