When I run the following lines of code the following erroe from the compiler is displayed
cannot find symbol - method start()
CODE:
import java.lang.Thread;
import java.util.concurrent.*;
public class MyThread
{
public static final int MAX = 15;
private String message;
/**
* Constructor with parameters
*
* @param message string to be used
*/
public MyThread(String m)
{
message = m;
}
/**
* run method always void nothing to be
* returned.
*/
public void run()
{
for(int i = 0; i <= MAX; i++)
{
System.out.println(message);
}
}
}
import java.lang.Thread;
import java.util.concurrent.*;
import java.util.*;
public class TestMyThread
{
public static void main (String[] args)
{
MyThread t1 = new MyThread("hello");
MyThread t2 = new MyThread("goodbye");
t1.start();
t1.join();
t2.start();
}
}