• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Thread...

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

public class SimpleThread extends Thread {
public void run ( ){
System.out.println ( "Executing simple Thread");
}
public void myThread() {
System.out.println ( "Executing myTthread() method");
}
public static void main ( String args [ ]) {
SimpleThread st = new SimpleThread ( );
st.start( );
st.myThread();
}
}
output of this program is::: Executing my thread()
Executing simple thread()
but i expected the output to be:: Executing simple thread()
Executing mythread()
anybody can tell me what im missing..
thanks..
regards.
Jaya Murugan
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anybody can tell me what im missing..
Actually nothing is missing and both the answers are correct.
starting a thread by st.start() does NOT guarantee that run() method will be invoked immediately.. It is up to the operating system when to make a thread running.. the start method only brings thread st into RUNNABLE state. but OS only decides when it runs mean while other methods can start executing.. like
myThread above..
HTH
Sasidhar

[This message has been edited by sasi dhulipala (edited January 09, 2001).]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic