Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

richard baldwin tutorial on threads  RSS feed

 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is the code that is used in richard baldwin's tutorials
but when i compile it, it gives error
someone please help
public class Trythreads
{
public static void main (String args[])
{
Mythread a = new Mythread();
Thread a1 = new Thread(a, "first");
Mythread b = new Mythread();
Thread b1 = new Thread(b, "second");
a1.start();
b1.start();
try
{
Thread.currentThread.sleep(1000);
}
catch (InterruptedException e)
{
}

System.out.println(Thread.currentThread());
}
}
class Mythread implements Runnable
{
public void run()
{
for(int i = 0 ; i < 5; i++)
{
System.out.println(Thread.currentThread());
System.out.println ("times = " + i);
}
}
}

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thread.currentThread().sleep(1000); // the brackets were missin

 
sona gold
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
silly me
thx
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!