Java deadlock question

前端 未结 3 1609
-上瘾入骨i
-上瘾入骨i 2020-11-28 11:41

can anyone explain me why there is a deadlock in this code.Thanks

public class Deadlock {
    static class Friend {
        private final String name;
               


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-11-28 12:08

    Best way to understand is put below code in bow() before calling bower.bowBack

    try {
    Thread.sleep(1);
    } catch (InterruptedException e) {
    e.printStackTrace();
    }
    

提交回复
热议问题