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