小编Bes*_*ver的帖子

为什么我们真的需要多个netty老板线程?

我真的很困惑老板组的线程数。我无法弄清楚我们需要多个老板线程的情况。在做,我们需要更多的比老板组单线程?Netty的创建者说,如果我们在不同的服务器引导程序之间共享NioEventLoopGroup,则多个老板线程很有用,但我不知道这样做的原因。

考虑以下简单的Echo服务器:

public class EchoServer {

private final int port;
private List<ChannelFuture> channelFutures = new ArrayList<ChannelFuture>(2);

public EchoServer(int port) {
    this.port = port;
}

public void start() throws Exception {

    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup(4);

    for (int i = 0; i != 2; ++i) {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup)
                .channel(NioServerSocketChannel.class) // the channel type
                .childHandler(new ChannelInitializer<SocketChannel>() {
                    @Override
                    public void initChannel(SocketChannel ch)
                            throws Exception {
                        System.out.println("Connection accepted by server");
                        ch.pipeline().addLast( …
Run Code Online (Sandbox Code Playgroud)

netty

8
推荐指数
1
解决办法
4099
查看次数

jvm字大小和操作数堆栈

JVM规范说jvm操作数堆栈以字大小为单位工作,在许多实现中,它是本机指针的大小 - 32位系统为4个字节,64位系统为8个字节.我的问题是,如果被推入堆栈的操作数是char(2个字节)并且操作数堆栈以字大小为单位推送和弹出操作数(64位系统中为8个字节),那么这不是浪费空间?

java jvm

5
推荐指数
1
解决办法
1254
查看次数

ping 不适用于 azure 上的 ubuntu 虚拟机

我在 azure 上创建了 2 个 ubuntu 虚拟机,我可以使用“ssh azureuser@xyz.cloudapp.net”从另一台机器登录到一台机器,但是从另一个虚拟机 ping 一个虚拟机没有响应。卷曲同样的事情。

ping xyz.cloudapp.net 
curl xyz.cloudapp.net 
Run Code Online (Sandbox Code Playgroud)

使用虚拟机的内部 IP 地址修改 /etc/hosts 文件也不起作用。

谢谢,

ubuntu hadoop azure

4
推荐指数
1
解决办法
6255
查看次数

C for循环,测试数组元素给出了奇怪的结果

我无法弄清楚我做错了什么.我想打印非零元素,下面的代码打印无.

#include <stdio.h>

int main ()
{
    int arr[4] = { 0, 3, 0, 7 };
    // print non zero elements
    for (int i = 0; i != 4 && arr[i] != 0; ++i)
        printf("%d\t%d\n", i, arr[i]);
}
Run Code Online (Sandbox Code Playgroud)

但是,如果我像下面那样移动阵列测试,它可以工作:

#include <stdio.h>

int main ()
{
    int arr[4] = { 0, 3, 0, 7 };
    // print non zero elements
    for (int i = 0; i != 4; ++i) {
        if (arr[i] != 0)
           printf("%d\t%d\n", i, arr[i]);
    }
}
Run Code Online (Sandbox Code Playgroud)

怎么了?

c for-loop

1
推荐指数
1
解决办法
60
查看次数

标签 统计

azure ×1

c ×1

for-loop ×1

hadoop ×1

java ×1

jvm ×1

netty ×1

ubuntu ×1