• Post Reply Bookmark Topic Watch Topic
  • New Topic

how control transfer in threads?

 
asheet anand
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please tell me that how a control transfer
in threads?
please tell me in respect of start() & run method?
why we get different output each time i run a thread program.
 
Udayan Naik
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi asheet.If you are talking about controlling threads in a synchronous controlled manner,then it's by means of synchronized keyword and the wait(),notify() nad notifyAll() methods.
If u mean in any other way,please be specific.

------------------
Come on in !! Drinks are on the house in the Big Moose Saloon !!
 
Mohan Guru
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai!
After creating a thread either by extending Thread or by implementing Runnable,you have to start the thread by calling
start().It inturn will call the run() where you have to put the
codings, to be executed by the thread.
You must call the start()only not run()in any condition.
When you are running two or more threads,the o/s will allot
the cpu,so that every thread has a chance to run.That is why you
getting differnt output.
It is important to have in mind that the time slicing is controlled only by the underlying o/s.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!