假設我有兩個類,主類和工人類線程和Java中觀察者模式
class Main implements StateChangeListener extends JFrmame{
public void notifyMe(State state){
//Change the GUI according to the state
}
}
class Worker extends Thread{
public StateChangeListener listener;
public void run(){
listener.notifyMe(state);
}
}
我的問題是: 假設工人在另一個線程運行,哪個線程將運行功能notifyMe()?
主線程或工作線程?謝謝
[Java多線程:執行對象方法的線程是否依賴於創建它的線程上的線程?](http://stackoverflow.com/questions/10243492/java-multithreading -does-the-thread-on-which-an-objects-method-is-executed-depe) – 2012-04-25 10:35:34