9.1 Creating a thread



To create a new thread is to create a new virtual-CPU and let it excute some code.
 
  1. Dinfining a class that implements interface Runnable, and override run() with code you want it run in the thread.
  2. Creating an object of that runnable class.
  3. Creating an object of class Thread, using the runnable object as its constructor parameter.
  4. Excuting the method start() of the Thread object to start the thread.
Case Study: SimpleRunnable.java

Next Page