0
我不明白爲什麼我無法啓動線程,我該怎麼做?IllegalMonitorStateException:對象未被線程鎖定
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;
}
如果(暫停)runUpdatePreOrders.wait();你呼籲等待不runUpdatePreOrders,但在「這個」對象 – Blackbelt 2013-02-15 10:30:13
我明白=)謝謝=) – 2013-02-15 10:33:34
不客氣 – Blackbelt 2013-02-15 10:34:11