我的java代码中有一个线程,如下所示。它在本地Dev和QC环境中运行良好。但有些数据缺少生产环境。以下帖子有问题吗?有什么方法可以重现它吗?
public class MyThread implements Runnable {
private ProcessBean processBean;
public MyThread(ProcessBean processBean) {
this.processBean = processBean;
}
public void run() {
processCommand();
try {
processData(processBean);
}catch (Exception e) {
e.printStackTrace();
}
}
private void processCommand() {
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public Boolean processData(ProcessBean processBean) throws Exception{
doSomething();
}
}
在下面的代码中,processData()方法将处理数据。所以有些数据没有被随机处理,没有任何线索。
线程的调用如下:
ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(2);
MyThread myThread = new MyThread(processBean);
scheduledThreadPool.schedule(myThread, 1, TimeUnit.SECONDS);
请帮帮我。