Java.NIO ソケット サーバーにスレッド プールがあります。Connection reset by peer
やBroken Pipe
などの実行時エラーが発生することがありました。
私の質問は: 例外がスローされたときにスレッドが強制終了されていますか? もしそうなら - スレッドプールで、殺されたスレッドの代わりに新しいスレッドが作成されていますか??
これは私の ThreadManager です:
import java.nio.channels.SocketChannel;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class ThreadsManager {
private ExecutorService threadPool = null;
private LiveConnectionsManager liveConnectionsManager;
private int threadPoolSize = 35; //number of tasks thread
public ThreadsManager(LiveConnectionsManager liveConnectionsManager) {
this.liveConnectionsManager = liveConnectionsManager;
threadPool = Executors.newFixedThreadPool(threadPoolSize);
ServerActions.threadPool = threadPool;
}
public void processNewMessage(SocketChannel socketChannel, Client client)
{
threadPool.execute(new MessagesProcessor(socketChannel, client, liveConnectionsManager));
}
public void closeConnection(SocketChannel socketChannel, Client client) {
threadPool.execute(new LogoutClient(socketChannel, client, null));
}
}