+ 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.
2 ответов
+ 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.
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().