which thread responsible to perform this code ? ?

Hello ,

is the follwoing code mean that when i create object of type f for example :

f ff=new f();

then this object (ff) will has its new thread then this new thread will perform run method or the thread whose create object ff will be responcible to perform all instructions in the construcuter (include run method) ?

class f {

f() { new Thread(new Runnable() {

public void run() {

System.out.println("i'm inside run method ") ;

}

}).start();

}

}

Thanks alot

[558 byte] By [nadaqam] at [2007-9-26 1:53:08]
# 1
The original thread creates the Thread object and calls the start method on it. The new thread will perform the run method.
schapel at 2007-6-29 3:03:48 > top of Java-index,Archived Forums,Java Programming...
# 2
The original thread creates the Thread object and calls the start method on it. The new thread will perform the run method.
schapel at 2007-6-29 3:03:48 > top of Java-index,Archived Forums,Java Programming...
# 3

The main thread is responsible to create the ff object.

see the output of this program.

class f {

f() {

System.out.println("before run"+Thread.currentThread().toString()) ;

new Thread(new Runnable() {

public void run() {

System.out.println("i'm inside run method "+Thread.currentThread().toString()) ;

}

}).start();

}

public static void main( String[] args ) {

f ff = new f();

}

}

sundaram123 at 2007-6-29 3:03:48 > top of Java-index,Archived Forums,Java Programming...