Rule No. 1 in Java: if you have more than one class in your application, you only can use "public" key word in the class which has main method (public static void main( ) ...).  Try the following code and name your file as Test2.java (not Test.java):

class Test implements Runnable {    // remove public key word here
public void run() {
for (int i=1; i<=10; i++){
System.out.println("Test:"+i);
}
}
}

public class Test2 {   // add public keyword here if you want to

public static void main (String args[]){

 Test te = new Test();
 Thread t = new Thread(te);
 t.start();

}
}


Compile Test2.java and run it:

C:\>java Test2


Cheer.

Reply via email to