Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PacketBuffer {
- private Lock lock = new ReentrantLock();
- private Condition notFull = lock.newCondition();
- private Condition notEmpty = lock.newCondition();
- Queue<String> packets = new LinkedList<String>();
- public void insert(String guid) throws InterruptedException {
- //FIXME
- lock.lock();
- try {
- while(packets.size() == Define.bufferSize) {
- System.out.println("Warteschlange voll, kann "+guid+" nicht annehmen.");
- //FIXME
- packets
- if (++?? == ???) ??? = 0;
- ++count;
- notFull.await();
- }
- packets.add(guid);
- System.out.println(guid+" ist jetzt in der Warteschlange.");
- //FIXME
- notEmpty.signal();
- } finally {
- //FIXME
- lock.unlock();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement