Search code examples
javamultithreadingrunnable

Java thread run method


In my pregame I have a thread and it's run method must have Queue as input:

@Override
public void run(Queue q) {
    // TODO Auto-generated method stub
    A = q.pop();
    System.out.println(A * A + "Pop1");

}

And in this case the run method is not an implemented method of my runnable class, so how can I handle this problem?


Solution

  • Set the queue as an argument in your constructor. Or add it in a setter. Remove the argument from the run method, but keep it in the method body.