Options
Java - Why am I getting constructor error for Thread
I'm following this "by the book" literally. Getting "cannot find symbol" for the Thread. It appears that the thread will only accept a string, when I'm giving it an object from my Process". The example from the book is the same.
Thanks!
public class Runner { public static void main(String[] args) { Process th1 = new Process("thread 2"); Thread thread1 = new Thread(th1); // Issues is here thread1.start(); System.out.println(Thread.currentThread()); } }
package dataanalyzer; public class Process implements Runnable { public String name; public Process(){ } public Process(String threadName) { name = threadName; } public void run(){ System.out.println(Thread.currentThread()); } }
Thanks!
Comments
-
Optionswestward Member Posts: 77 ■■□□□□□□□□Well I solved my own problem. I had implemented the Runnable class manually, and made an error there. Removing the Runnable class override and letting it run without declaration solved the problem.