I have thread BLOCK issue. Please help me. In my class, i have two objects. One is for for synchronizing threads and the other is for doing actual business operations.
Here is my Class
Class A{
Object lock = new Object();
B b = new B();
public addSomething(){
synchronized(lock){
b.doThis();
}
}
}
I have a single instance of class A that is 'a' and from multiple threads accessing the method a.addSomething(). I开发者_运维技巧 am encountering thread BLOCK issue for this.
The problem probably is in b.doThis()
. If it isn't well-behaved (it takes a very long time to execute or may never finish) all other threads that call addSomething
will be blocked.
精彩评论