• Post Reply Bookmark Topic Watch Topic
  • New Topic

richard baldwin tutorial on threads  RSS feed

 
sona gold
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);
}
}
}

 
Angela Narain
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!