1 package com.common.test;
 2 
 3 import java.util.LinkedList;
 4 
 5 class Stack     
 6 {        
 7      LinkedList list = new LinkedList();     
 8     
 9     public synchronized void push(Object x)     
10     {   
11         synchronized(list) {  
12             list.addLast( x );               
13             notifyAll();
14        }     
15      }     
16     
17     public synchronized Object pop() throws InterruptedException     
18     {   
19         synchronized(list)  {
20             while( list.size() <= 0 ) { 
21                 wait();
22             }
23             return list.removeLast();     
24         }     
25    }     
26      
27  }  
28 

看看这段代码有什么问题?

相关文章:

  • 2021-07-31
  • 2022-12-23
  • 2021-11-29
  • 2021-07-28
  • 2021-05-25
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-08
  • 2022-01-16
  • 2021-10-23
  • 2021-07-07
  • 2022-02-13
  • 2019-07-15
相关资源
相似解决方案