我在抽象类中有一个代码:
public abstract class Job implements Runnable{
public void start(Integer jobId) {
try {
new Thread(this).start();
} catch (Exception e) {
e.getMessage();
}
}
}
班级代码:
public class Test extends Job {
@Override
public void run() {
for(int i = 0; i < 5; i++) {
try {
Thread.currentThread();
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("TEST");
}
}
}
主要我有:
public static void main (String[] args) throws MessagingException
{
Test test = new Test();
test.start(74);
}
那么如何将参数(jobId)从 start 方法传递给 run()?