Options

Java - Why am I getting constructor error for Thread

westwardwestward Member Posts: 77 ■■□□□□□□□□
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.
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

  • Options
    westwardwestward 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.
Sign In or Register to comment.