I want to use an anonymous class for Runnable
. There are two ways, but I don't know if they do the same thing or not:
Method one: using Runnable
directly and then calling run()
:
new Runnable() {
@Override
public void run() {
}
}.run();
Method two: create an anonymous Runnable
and paste to Thread
, using the start()
method instead of run()
:
new Thread(new Runnable() {
@Override
public void run() {
}
}).start();
I think method two is obviously true. But, I don't know if it does the same thing as method one. Can we call the run()
method on a Runnable
directly?