There seem to be a number of different ways in which one can create threads (Runnable vs Thread class) and also ThreadPools.
Are there any difference in terms of efficiency and which are the most efficient (in terms of performance) techniques for creating and pooling threads in Java?
At the end of the day, they’re all relying on the same underlying
Thread-based mechanism to actually do the work. That means that if you are asking “what is the most efficient way to start a single thread?” the answer is, create aThreadobject and callstart()on it, because any other method will take some other steps before it eventually creates aThreadobject and callsstart()on it.That doesn’t mean that this is the best way to spawn threads, it just means that it is the most low-level way to do it from Java code. What the other ways to create threads give you is different types of infrastructure to manage the underlying
Threads, so your choice of method should depend on the amount and kind of infrastructure you need.