Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-06-2008, 02:20 AM
Member
 
Join Date: Oct 2008
Posts: 18
piyu.sha is on a distinguished road
[SOLVED] Can two threads call two different synchronized instance methods of an Objec
Can two threads call two different synchronized instance methods of an Object?

I am still not sure on this, If I have two different methods in a object and two different threads are calling them.....is it possible?

Not sure if I understood the question right.... but looks like really fundamental question. Please provide your suggestions and pointers...
__________________
Live life king size
[
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
]
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-06-2008, 02:22 AM
Member
 
Join Date: Oct 2008
Location: US
Posts: 40
kzvi.kzvi.1 is on a distinguished road
No. If a object has synchronized instance methods then the Object itself is used a lock object for controlling the synchronization. Therefore all other instance methods need to wait until previous method call is completed.
See Sample Code which demonstrate it very clearly.

____________________________________________
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 10-06-2008, 02:25 AM
Member
 
Join Date: Oct 2008
Posts: 45
priyanka.dandekar is on a distinguished road
Try out some code yourself, it should be more easier. Also it will be memorized. You can try more combination on same multi threaded applications.

____________________________________________
Priya,
Cooking is Fun | Eat Healthy Stay Fit | Sweets | Raita | Bread | Dal
__________________
Cheers,

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 10-06-2008, 02:27 AM
Member
 
Join Date: Oct 2008
Posts: 45
priyanka.dandekar is on a distinguished road
Btw just to answer your question,
You cannot call two synchronized methods of a class on the same object. This is the use of synchronization. If you can call two synchronized methods on the same object then there is a chance of corruption of the state of the object. Synchronization helps you to avoid this....

____________________________________________
Priya,
Cooking is Fun | Eat Healthy Stay Fit | Sweets | Raita | Bread | Dal
__________________
Cheers,

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


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Threads - synchronized JavaForums Java Blogs 0 08-24-2008 04:24 PM
How to call methods of different classes adeeb New To Java 2 06-06-2008 08:08 AM
How to synchronize threads on an object Java Tip java.lang 0 04-09-2008 08:39 PM
How can I call java class methods in Oracle 10g PL/SQL searcher34 Database 0 01-02-2008 03:52 PM
accessing instance variables from static methods ravian New To Java 5 11-08-2007 10:53 AM


All times are GMT +3. The time now is 08:07 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org