I have written the following java code for runnable approach for creating new thread and getting errors as given below after the codes. If anyone can help me sort out this thing would be appreciated.
The errors are as follows:
You have to pay attention to the upper and lower case of the class names. That way, "thread" becomes "thread." Also use thread#currentthread, not thread#currentthread, this method does not exist. The same goes for thread#sleep and the constructor.
Example:
public final class ThreadDemo implements Runnable {
@Override
public void run() {
Thread currentThread = Thread.currentThread();
Thread executingThread = new Thread(this, "Demo-Thread");
executingThread.start();
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
}
Also it is not possible to have a method 2 times in one class. So remove a run method. Also, next time I ask you to use the codeblock and no images.