📄 bytebufferpool.java
字号:
/* * Copyright (C) butor.com. All rights reserved. * * This software is published under the terms of the GNU Library General * Public License (GNU LGPL), a copy of which has been included with this * distribution in the LICENSE.txt file. */package org.butor.socket.nio;import java.nio.ByteBuffer;import java.util.Stack;/* *TODO * * @author sawanai * @date Feb 14, 2006 */public class ByteBufferPool { // pool of StringBuffer protected static Stack stack = new Stack(); protected static ByteBuffer getStringBuffer() { synchronized (stack) { if (stack.size() > 0) { ByteBuffer bb = (ByteBuffer) stack.pop(); return bb; } } return ByteBuffer.allocate(512); } protected static void keepByteBuffer(ByteBuffer bb) { synchronized (stack) { if (stack.size() < 1000) { //keep 1000 maximum bb.clear(); stack.push(bb); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -