public class MyQueue { class QueItem { String item; QueItem next; public QueItem(String s) { item = new String(s); } } private QueItem begin,end; public synchronized void add(String s) { QueItem n = new QueItem(s); end.next = n; end = n; } public synchronized String get() { String result = new String(begin.item); begin = begin.next; return result; } }