Java: What's the difference between Thread start() and Runnable run()?

First: No multiple threads. Both execute in single (existing) thread. No thread creation.

First: No multiple threads. Both execute in single (existing) thread. No thread creation.

R1 r1 = new R1(); R2 r2 = new R2(); r1 and r2 are just two different objects of the class that implements the Runnable interfaces which have that run method. Second: Two separate threads. Thread t1 = new Thread(r1); Thread t2 = new Thread(r2); t1 and t2 are the objects of the class Thread, which have the ability to start a new thread and execute the code within the run method in a new thread.(e.g. With t1.start(), it starts a new thread and calls the run method of r1 internally to execute it within that new thread).

If you just invoke run() directly, it's executed on the calling thread, just like any other method call. Thread.start() is required to actually create a new thread so that the runnable's run method is executed in parallel.

In the first case you are just invoking the run() function of the r1 adn r2 objects. In the second case you're actually creating 2 new Threads! ;) start() will call run() at same point!

Actually, start() won't call run(): if it did, then the run() method would get executed by the same thread that called start(). What start() will do is create a thread which will call the run() method. – Bruno Reis Dec 22 '11 at 4:44.

Thread.start() Register the Thread with scheduler and the scheduler calls the run() methods Thread is class and runnable is interface.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions