The Thread class itself implements Runnable. (After all, it has a run() method that we were overriding.) This means that you could pass a Thread to another Thread’s constructor:
Thread class run () method
@Override
public void run() {
if (target != null) {
target.run();
}
}
Here, target is the runnable class which is passed during make threads using runnable interface.
Four constructor of thread class:
■ Thread()
■ Thread(Runnable target)
■ Thread(Runnable target, String name)
■ Thread(String name)
No comments:
Post a Comment