I have a tcp server running at port xxxx and flash policy server(again tcp) at port 843. Is it ok if I pass the same ExecutorService instance while creating the server bootstrap’s for both servers? Will it lead to data corruption?
ExecutorService boss = Executors.newCachedThreadPool(new NamedThreadFactory("TCP-Server-Boss")
ExecutorService worker = Executors.newCachedThreadPool(new NamedThreadFactory("TCP-Server-Worker")
serverBootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(boss,worker))
Now I want to pass the same boss and worker to the flash policy servers serverBootstrap. Is this a valid usage?
The
ExecutorServicereturned bynewCachedThreadPool()is not guaranteed to be threadsafe anywhere in the documentation. So it would be the correct action to create two newExecutorServices.Im quite sure the instances returned are threadsafe regardless of the documentation, but I would still make two new
ExecutorServices with different names to ease debugging and readability.