• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Thread start() method is static or not ?

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is a sample code from 1 of the mock exams , the start() method of the Thread class in not static, here the method is called just as start() . so the code should give compiler error, is that rite ?


public class Tux extends Thread
{
static String sName = "Techno";
public static void main(String argv[])
{
Tux t = new Tux();
t.name(sName);
System.out.println(sName);
}
public void name(String sName)
{
sName = sName + " park";
start();
}
public void run()
{
for(int i=0;i < 4; i++)
{
sName = sName + " " + i;
}
}
}
 
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Calling start() is the same as this.start() which runs on the current instance.
 
Just the other day, I was thinking ... about this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic