开发者

Thread BLOCK issue in java

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜