Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Good link (Threads)

 
Ramnath krishnamurthi
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I came across this good article on how JVM implements synchronization behind the hood.
web page.
Hope this will help other certification aspirants like me.
Ramnath
Modified title to be more specific...
[ April 10, 2004: Message edited by: Barry Gaunt ]
 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is a great article to certain extent. It gives similar explanation as some books with respect to accessing a synchronized method.
After reading the article, I still have the question:"When there is a synchronized method in the object and a thread gets a lock, is the lock on the whole object or just the method??"
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After reading the article, I still have the question:"When there is a synchronized method in the object and a thread gets a lock, is the lock on the whole object or just the method??"

The whole object but non synchronized metods can be accessed by multiple threads.
 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the whole object is locked by the thread, how are other threads entering other methods. beats me!!
 
shaggy lype
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey kishore this might not be the correct answer but i think it is,
well every object has synchronized methods and methods which are not synchronized for which a thread don't need a lock so a thread can enter an object and run those methods but not the synchronized method until other thread give up the lock. I hope ur question is answered.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic