Goals
- Uniquely identify a Thread within one JVM
Thread/Runnable
- Each thread provides a thread id that is unique within one JVM
- Threads can only be started once (a second start will result in an exception)
- Thread pools
- Application server usually make use of thread pools, that is they re-use threads and just provide new Runnable instances to thread
- Thus the thread ID is not uniquely identifying a job that is executed by a thread, but one thread ID will in fact run multiple jobs
- The new Executor classes in Java6 provide an implementation of a thread pool
- Runnables
- Are used to execute jobs (in fact each Thread defines its functionality as Runnable)
- Runnables can be reused