when Thread.sleep(10000) is invoked current Thread will go to sleeping state. If Thread.sleep(10000) is invoked in synchronization method whether other thread can execute in that period?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
If you do
Thread.sleep(10000)
within a synchronized method or block you do not release the lock. Hence if other Threads are waiting on that lock they won't be able to execute.If you want to wait for a specified amount of time for a condition to happen and release the object lock you need to use
Object.wait(long)
I made this method as synchronized,I run two separate threads which are running concurrently & executing this method producing unwanted results!! If i comment the try catch block it will run fine,So is the synchronized block use is limited till m not using these try catch block