@Futurama , the answer to your question is clearly stated in the documentation .
We read (bold - this is highlighted by me):
There are two ways to create a thread of execution. One is to declare a class to be a subclass of Thread . This subclass should override the run method of class thread . An instance of the subclass can then be allocated and started. For example, it could be written as follows:
class PrimeThread extends Thread { long minPrime; PrimeThread(long minPrime) { this.minPrime = minPrime; } public void run() { // compute primes larger than minPrime . . . } }
The following code would be to create a thread and start it running:
PrimeThread p = new PrimeThread(143); p.start();
The bottom line is that we override the run method of the class Thread, which is called from the start method of the class Thread, which we call to start the thread (executing our program in a new thread).
Declare a class that implements the Runnable interface . That class then implements the run method . An example of this can be defined as a thread, and started. It looks like the following:
class PrimeRun implements Runnable { long minPrime; PrimeRun(long minPrime) { this.minPrime = minPrime; } public void run() { // compute primes larger than minPrime . . . } }
The following code would be to create a thread and start it running:
PrimeRun p = new PrimeRun(143); new Thread(p).start();
In principle, as they say - "the same eggs, side view."
If you think about it, the essence is the same. A new thread is created (prepared for launch) (Thread class is a data structure inside the JVM). This structure contains the address of the function (JVM instruction sequence), which represents the program that we want to run in the new thread. Calling the .start method of the class Thread (directly or indirectly, as inherited in the first case) will launch a new thread (exactly how it depends on the OS in which the particular JVM works).
That's all. Just RTFM.