Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need Clarification  RSS feed

 
Arnab karmakar
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please consider the following codes :

synchronized(object) {
try {
Thread.sleep(100000);
} catch(InterruptedException e) {
}
}

If this is a code which is executed by a thread, then as far as sleep's specification is concerned, it will not free the lock which is currently on object.

Is it possible to use the "object" to do some other opnerations on it?

Thanks
Arnab
 
Amit A. Patil
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Offcourse all non synchronized methods are there @for your service without blocking other threads
 
Arnab karmakar
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for leaving some part of the question.
Can we call the synchronized blocks of the object?
 
Amit A. Patil
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No Sir unless its a static synchronized block
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calling sleep() while holding a lock is generally looked at as a Bad Thing.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!