This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

compile time errors

 
Ranch Hand
Posts: 127
  • 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 ]
 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
 
    Bookmark Topic Watch Topic
  • New Topic