File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes Thread synch Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "Thread synch" Watch "Thread synch" New topic
Author

Thread synch

Ruslan Ivanov
Ranch Hand

Joined: Feb 22, 2001
Posts: 72
Hi i have this sample in myboo where they have a synch method defined as follows
public syncrhonized void send(Object obj){
que.addElement(obj);
}
now que is a vector why would i want to make send method synch if all the methods in vector are already synch this doesn't make sence to me. What does this accomplish ? I understand if i had something more going on in this method like changing state of a variable that has someting to do with my object then yes it would make sence to make it synch so other threads can't access this method until the first one in won't unlock it. Otherwise what's the point of this ?Thanks.
Rahul Rathore
Ranch Hand

Joined: Sep 30, 2000
Posts: 324
See this discussion http://www.javaranch.com/ubb/Forum27/HTML/000259.html
Mark Savory
Ranch Hand

Joined: Feb 08, 2001
Posts: 122
Ruslan,

The object that contains the method 'send' must be locked before calling 'send'. Maybe there's another method in that object that must be synchronized with 'send' for whatever reason.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Thread synch
 
Similar Threads
Mnemonics for the SCJP?
Using a Vector within a Vector
My Locking Approach
can someone help me out
Do You Really use two db files?????!!!