I am making a server, and the server creates a thread for each client that connects. That thread will have an open inputstream which it will monitor for incoming messages. The Runnable of that thread will be called ServerListenerRunnable for this example.
I am conflicted whether to use Executor or just run the thread straight away.
For example
Runnable listener = new ServerListenerRunnable();
Executor executor = Executors.newSingleThreadExecutor();
executor.execute(listener);
Is this somehow better than just running
new Thread(new ServerListenerRunnable()).start();
And can you tell me why?
And if you have some time to kill, can you explain in general why using Executor is better than running the thread straight away or vice versa.
Thank you in advance.