// The "Tester" class.
import java.applet.*;
import java.awt.*;
public class Tester
{
public static void main (String[] args)
{
ThreadTest ex1 = new ThreadTest ();
ThreadTest2 ex2 = new ThreadTest2 ();
ex1.start ();
ex2.start ();
}
} //Tester class
public class ThreadTest extends Thread
{
public ThreadTest ()
{
}
public void run ()
{
while (true)
{
System.out.println ("Hello");
delay (1000);
}
}
public void delay (int num)
{
Thread.currentThread ().setPriority (Thread.MIN_PRIORITY);
try
{
Thread.sleep (num);
}
catch (InterruptedException ex)
{
ex.printStackTrace ();
}
Thread.currentThread ().setPriority (Thread.MAX_PRIORITY);
}
} // ThreadTest class
public class ThreadTest2 extends Thread //This is where the error is
{
public ThreadTest2 ()
{
}
public void run ()
{
while (true)
{
System.out.println ("Hello2");
delay (1000);
}
}
public void delay (int num)
{
Thread.currentThread ().setPriority (Thread.MIN_PRIORITY);
try
{
Thread.sleep (num);
}
catch (InterruptedException ex)
{
ex.printStackTrace ();
}`enter code here
Thread.currentThread ().setPriority (Thread.MAX_PRIORITY);
}
} // ThreadTest2 class
I don't understand the error that pops up every time i try to run the code. The error that pops up is
"The type "ThreadTest2" is declared public in compliation unit "G:/Java/newstuff/Tester.java" which also contains the public type, "Tester""