1 |
One can implement threads in two ways
-
Firstly subclassing the Thread class and overriding its run() method
-
Secondly by creating a Thread with a Runnable object (i. e. that implements Runnable interface)
|
2 |
Only the second way is possible for applets as these already extend Applet class and so cannot multiply inherit from the Thread class
|
3 |
Threads must have a run method which is code Thread executes.
|
4 |
If you are using first way, this is written for this particular thread and overrides run() in Thread class
|
5 |
In second way, the created Thread automatically takes its run() method to be the run method of the applet
|