• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compile time errors

 
Venkat Ramsimha
Ranch Hand
Posts: 127
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi All,
can anybody provide the explanation as why the above program is giving compile time errors

thanks
venkat

([B] tags added and formatted[/B])
[ May 12, 2005: Message edited by: Barry Gaunt ]
 
Timmy Marks
Ranch Hand
Posts: 226
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need a run method with no arguments if you implement Runnable
 
Kumar J
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Venkat Ramsimha:
public class Fooaw implements Runnable
{
void run (Thread t)
{
System.out.println("Running");
}
public static void main (String[] args)
{
new thread (new Fooaw()).start();
}
}
Hi All,
can anybody provide the explanation as why the above program is giving compile time errors

thanks
venkat



where have you declared thread class ?
and where have u declared run() ?


[ May 12, 2005: Message edited by: Mr Kumar J ]
[ May 12, 2005: Message edited by: Mr Kumar J ]
 
Timmy Marks
Ranch Hand
Posts: 226
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thread is part of java.lang

the run method is defined in the Runnable interface; also part of java.lang
 
Kumar J
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Timmy Marks:
Thread is part of java.lang

the run method is defined in the Runnable interface; also part of java.lang


Hi timmy, he has declared thread whose first letter is small t which is not Thread you are talking.and run() as you said earlier he has not defined.

 
Timmy Marks
Ranch Hand
Posts: 226
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I didn't look closely enouth to notice that a thread was instantiated instead of a Thread. Either way, it won't compile because the Runnable interface is not implemented.
 
Venkat Ramsimha
Ranch Hand
Posts: 127
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats fine but anybody can correct the compile time errors which iam facing and provide the explanation for that?

thanks in advance,
venkat
 
Timmy Marks
Ranch Hand
Posts: 226
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have already told you the two main problems with the code.

With the two corrections mentioned:
1. Runnable interface requires a method
public void run()

2. Thread is a class, thread is a typo

the code will work
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic