美文网首页
netty笔记-ByteBufAllocator

netty笔记-ByteBufAllocator

作者: 兴浩 | 来源:发表于2018-07-02 17:11 被阅读10次

ByteBufAllocator可以理解为ByteBuf的工厂

1.ByteBufAllocator接口方法

2.Unpooled工具类

提供了方便的辅助静态方法,内部由UnpooledByteBufAllocator实现

测试代码:

    @Test
    public void byteFactory() {
        {
            ByteBuf buf = Unpooled.buffer(16);
        }

        {
            ByteBufAllocator allocator = new PooledByteBufAllocator(false);
            ByteBuf buf = allocator.buffer(16);
        }
    }

相关文章

网友评论

      本文标题:netty笔记-ByteBufAllocator

      本文链接:https://www.haomeiwen.com/subject/ywmluftx.html