public class Solution {
public static class TestThread implements Runnable{
public void run(){
System.out.println("My first thread");
}
}
public static void main(String[] args) {
TestThread task = new TestThread();
new Thread(task).start();
}
}
Andrei
Level 41
Why do we have to use new Thread(task).start(); instead of just task.start() ?
Resolved
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Vincenzo Seggio
11 December 2020, 10:14solution
Because TestThread do not inherit from Thread.
In this case you can write
task.start(); +3
Andrei
11 December 2020, 10:21
Thank you!
0