1
public class Sample extends Panel {
// Constructor
public Sample() throws IOException {
/* JobOne and JobTwo need to be implemented using Thread at same time */
JobOne{
//statements
}
JobTwo{
//statements
}
}
public static void main(String[] args) throws IOException {
new Sample();
}
}
如何執行此操作,如果需要這些東西在構造函數內部實現?如果我無法擴展Thread(因爲我已經擴展了另一個類),我該如何平行執行語句?
這很好。但將在一個構造函數中做到這一點? – nebula
@aneal:你的意思是聲明構造函數中的runnable?或者你是在談論實現Runnable的構造函數中的內容? –
我的意思是第二個。 – nebula