Why we we use Runnable interface even it has no connection with start()
method? Why we can't just write run()
method and start?
Why we need to implement run()
method,instead of using it directly and start process using start()
method?
Why we we use Runnable interface even it has no connection with start()
method? Why we can't just write run()
method and start?
Why we need to implement run()
method,instead of using it directly and start process using start()
method?
If you just called the run
method directly, it would run on the thread you used to call it. By implementing Runnable
and passing your instance into new Thread
, you're setting it up so that run
will be called on the new thread.
I recommend working your way through the Java Concurrency tutorial, which will go into creating and running threads in detail.