import java.util.LinkedList; import java.util.List; // This class maintains a statically-allocated pool of memory buffers public class BufferPool { public static final int BUFFER_POOL_SIZE = 512; public static class Buffer { public static final int BUFFER_SIZE = 1024; private byte[] data; public Buffer(){ data = new byte[BUFFER_SIZE]; } public byte[] getData() { return data; } } // Note: the list is not internally thread-safe. // So, every read and write must be synchronized private final List freeBuffers = new LinkedList(); public BufferPool() { for (int i=0;i