Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Threads  RSS feed

 
Alpana Singh
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am preparing for SCJP exam 035.I am a beginner and Threads is tough.I have a question related to threads.The following program

public class Foo28 implements Runnable{
public void run(Thread t){
System.out.println("Running");
}
public static void main(String args[]){
new Thread(new Foo28()).start();
}
}

It give an error at line 1 that Foo28 doesn't implement abstract method run().But I think it will should also give an error on line 2.Please advise.
 
Satish Chilukuri
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The signature for the run() method of Runnable is public void run(). It has no arguments. The compliler didn't complain about line 2 as it is a valid method declaration. It did complain about line 1 as you haven't provided an implementation for the run() method of Runnable.
 
Alpana Singh
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Satish
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!