We are trying to optimize our code for performance, since our system is very performance critical.
- Posted by: Paresh Shah
- Posted on: June 26 2001 17:42 EDT
In a particular scenario, we try to get hold for a particular resource and if we cant get we have
thread.sleep(5000) before making another attempt. There are other threads which still should be running during this time. From the log, though it seems that(I am not dead sure) when it tries this attempts, it does not do any processing on other threads.
Is it necessary to do a yield after this sleep? or will the sleep still allow the other threads to go ahead and not block it any way.
No is the easy answer. sleep(long) will release all synchronization locks held by that thread, but will reacquire them when it wakes up. Do your other threads also sleep when they are locked out? If so then you could just be ending up in the perpetual sleep state?
Are you sure your threads are not synchronizing on some central object which is causing a deadlock?
There are many many many many (get the idea) possible reasons this could be happening. Would need to see the code to work it out.