How does ExecutorService + newFixedThreadPool "reuse" threads?
I'm trying to fully understand how ExecutorService + newFixedThreadPool work. I understand the example on the Java API, and have made a few test applications of my own... but what I don't understand is how they are able to reuse threads.
In a test application of my own, I made an instance of newFixedThreadPool with a pool size of 3. I then ran about 10000 small Callables through it. Through the use of println()'s and observation through jconsole, I was able to confirm that the pool did in fact only create 3 threads to run through all the callables I was sending it.
From what I understand about threads, isn't a thread tied to a single Runnable? Therefore, how are the same 3 threads being reused to run 10000 callables?
Any insight is appreciated, this is really bugging me :)