• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

compile time errors

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need a run method with no arguments if you implement Runnable
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic