Blocking Queue

View previous topic View next topic Go down

Blocking Queue

Post  Admin on Mon Nov 21, 2011 3:15 pm

public class BlockingQueue{
private List queue=new LinkedList();
private int limit=10;
public BlockingQueue(int limit){
this.limit=limit;
}

public synchronized void enqueue(Object item){
while(this.queue.size()==this.limit){
wait();
}
if(this.queue.size()==0){
notifyAll();
}
this.queue.add(item);
}
}

Admin
Admin

Posts : 131
Join date : 2011-08-16

View user profile http://codefornongeek.forumotion.com

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum