使用Runnable還是有一點小問題,因為一個物件一旦implement了Runnable,
那就只能使用一個run,這就是說,使用介面的方式呢,只能使一個物件有
一個thread,當然我們還是可以繼承Thread而攔截run,然後開多個物件來
達到多執行緒的效果,但既然Java有使用介面的方式來完成multi-thread
,為何一個物件使用implement的方式就只能達成一個thread呢?
我倒是有個建議,就是implement的後面加個編號,例如說這樣:
class MyThread implements(1) Runnable implement(2) Runnable
{
void run.1()
{
...
}
void run.2()
{
...
}
}
哈哈!這樣的話可就沒有問題了,不過好像太過『複雜~~~』了!^_^
--
Power is unreal. Money is useless. Doctrine is a mistake in human society.
The human society, however, is a mistake itself. Change brings unstability.
Evolution leads to war. Life has no meaning if you want some. Goal for living
must be obtained by yourself. Nothing counts if you don't seek for it.
--
※ 發信站: 批踢踢實業坊(ptt.m8.ntu.edu.tw)
◆ From: ntucsv.csie.ntu