In Java thread topic, the task to be executed and the thread to drive the task are two concepts should be clarified. The working process is like the following:
- Create one task
- Create one thread to be attached on your created task.
In Java, thread is not the task itself. The Runnable interface is used to describe the real task. Also, the name of Runnable is a bad choice for describing its job.
So, let's summarize these concepts with Java code:
[Concepts: Java Implementation]
- task: described by Java interface Runnable.
- mechanism to drive task: Java's Thread class.