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?
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.
You write a second run
method with the right signature for Runnable
. This one can then get the queue somehow and call the other run
method.
from the original run() method of the thread , call run(Queue q) method
@Override
public void run() {
//call the run(Queue q) method from here
}
public void run(Queue q) {
// TODO Auto-generated method stub
A = q.pop();
System.out.println(A * A + "Pop1");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.