View Single Post
  #2 (permalink)  
Old 10-06-2008, 08:32 AM
kzvi.kzvi.1 kzvi.kzvi.1 is offline
Member
 
Join Date: Oct 2008
Location: US
Posts: 40
kzvi.kzvi.1 is on a distinguished road
Looks like you are having problem understanding the core fundamental of synchronization. You should start writing code for testing all these scenarios.

To answer your question.

Yes, a Non synchronized method can always be called without any problem. In fact Java does not do any check for a non-synchronized method. The Lock object check is performed only for synchronized methods/blocks. In case the method is not declared synchronized Jave will call even if you are playing with shared data. So you have to be careful while doing such thing. The decision of declaring a method as synchronized has to be based on critical section access. If your method does not access a critical section (shared resource or data structure) it need not be declared synchronized.

See the Example Code which demonstrate the same.

____________________________________________
Software Wiki | Interview FAQs | Lucene Search | Oracle | ORM | Struts2 | Job Seeker
__________________
Have fun....

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Reply With Quote