Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

wat is the purpose of start()  RSS feed

 
kotha vijaybabu
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ranchers...,

as v know dat start() is used to call run() implicitly...
it is also possible dat v call directly run()

then wat is the use of start()...

i mean to say dat wat is da difference when v call run() directly and with da use of start()

thanks in advance


vijay
 
Vinny Menon
Ranch Hand
Posts: 62
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vijay
When we call run() directly ,it will execute in the main thread just a normal execution.
Where as when we call start(),it will execute on the separate thread that has been created by the user.
hth
Cheers
Vinny M
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vinny Menon:
Hi Vijay
When we call run() directly ,it will execute in the main thread just a normal execution.
Where as when we call start(),it will execute on the separate thread that has been created by the user.
hth
Cheers
Vinny M


Almost. Invoking run() will not execute the code in the main thread, it will simply execute the code from whatever thread invoked it. This is not necessarily the main thread, but it could be. Furthermore, I think it's important to understand that start() is a native method that starts a new thread of execution. I think it would perhaps be more accurate to say it's a separate thread created by the JVM, not the user.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!