1 2
| LinkedList<ByteBuffer> dataQueue; dataQueue = Collections.synchronizedList(new LinkedList<ByteBuffer>()); |
comes back incompatible type
1 2
| LinkedList<ByteBuffer> dataQueue; dataQueue = new LinkedList<ByteBuffer>(); |
works fine, but I know is not synchronized.
1 2
| List<ByteBuffer> dataQueue; dataQueue = Collections.synchronizedList(new LinkedList<ByteBuffer>()); |
does not give me access to the poll() command that I want.
Will this be safe for the second example above?
1 2 3 4 5
| public synchronized void addDataToQueue(ByteBuffer b) {
dataQueue.add(b); } |