我不明白为什么我不能启动一个线程,我该怎么做?
scheduleTaskExecutor = Executors.newScheduledThreadPool(1);
scheduleTaskExecutor.scheduleAtFixedRate(runUpdatePreOrders, 0,
timeRepeat, TimeUnit.MILLISECONDS);
private Runnable runUpdatePreOrders = new Runnable() {
public void run() {
synchronized (runUpdatePreOrders) {
try {
if (pause) wait();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
new UpdateOrders(min_price, listener).execute();
Log.e("UpdateBrodcast", "StartPreOrder");
}
}
};
@Override
public void onStart() {
super.onStart();
if (pause) {
runUpdatePreOrders.notify(); // this IllegalMonitorStateException: object not locked by thread before
}
pause = false;
}