# HG changeset patch # User Yu Taninari # Date 1310183913 -32400 # Node ID 129e999a2aa3967141ec4edba7b07a601befd08e # Parent 1b5d30103205028a398cf01f4ef82135426ce559# Parent 672e7582bcce517ddbe4fc60c779978ddd2b2f6f merge diff -r 1b5d30103205 -r 129e999a2aa3 bin/java.policy.applet --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/java.policy.applet Sat Jul 09 12:58:33 2011 +0900 @@ -0,0 +1,7 @@ +/* AUTOMATICALLY GENERATED ON Tue Apr 16 17:20:59 EDT 2002*/ +/* DO NOT EDIT */ + +grant { + permission java.security.AllPermission; +}; + diff -r 1b5d30103205 -r 129e999a2aa3 src/myVncClient/MulticastQueue.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/myVncClient/MulticastQueue.java Sat Jul 09 12:58:33 2011 +0900 @@ -0,0 +1,75 @@ +package myVncClient; + +import java.util.concurrent.CountDownLatch; + +public class MulticastQueue +{ + + Node tail; + + public MulticastQueue() + { + tail = new Node(null); + } + + public synchronized void put(T item) + { + Node next = new Node(item); + tail.set(next); + tail = next; + } + + public Client newClient() + { + return new Client(tail); + } + + static class Client + { + Node node; + + Client(Node tail) + { + node = tail; + } + + public T poll() + { + Node next = null; + + try { + next = node.next(); + }catch(InterruptedException _e){ + _e.printStackTrace(); + } + node = next; + return next.item; + } + } + + private static class Node + { + private T item; + private Node next; + private CountDownLatch latch; + + public Node(T item) + { + this.item = item; + this.next = null; + latch = new CountDownLatch(1); + } + + public void set(Node next) + { + this.next = next; + latch.countDown(); + } + + public Node next() throws InterruptedException + { + latch.await(); + return next; + } + } +}