Sunday, 13 September 2015

Instantiating a Thread for runnable interface

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

    public void run() {
        if (target != null) {

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

Related Posts Plugin for WordPress, Blogger...