+ 1

what means an argument from a object be like this: thread ob = new thread(new A()); ???

the part new A() i don't get yet.

23rd Jul 2016, 9:53 AM
Gorick X
Gorick X - avatar
2 Respuestas
+ 1
new A() just means a class named A was used to implement Runnable interface and contain the required run() method. The thread calls on the class in order to run it. Otherwise, you'd have to extend Thread and do the run method in the original class.
23rd Jul 2016, 12:59 PM
James
James - avatar
0
Hello Gorick..the new A() you have written is one way to create object and pass it as an argument. It's anonymous object because you havent specified the name of object and hence JVM initialises anonymous object due to new keyword and it belongs to class A where you have implemented run().
23rd Jul 2016, 1:18 PM
Yatin Gaikwad