2010-09-07 67 views
0

我正在開發一個Android應用程序,我需要在線程上工作,這是一個衆所周知的Java概念。我在我的應用程序中有一個名爲「thrd」的線程,我想在IF的其他部分調用它... Else循環。在Android中調用線程

任何人都可以請告訴我怎樣才能在我的循環中調用該線程,對於使用Java或Android而言,對於我來說這是全新的。

感謝提前的幫助下, 大衛

+0

你在做什麼你的線程?在Android API中可能會有一些與香草Java線程相比更好的匹配。 – 2010-09-07 08:28:49

回答

0

線程只是Java對象,所以你必須要啓動線程的線程參考。我認爲這是不可能的(或者如果可能的話,不是一個好主意)來獲得這樣一個參考表單作爲線程名稱。這裏是代碼示例開始使用線程:

// This class extends Thread class 
BasicThread1 extends Thread { 
    // This method is called when the thread runs 
     public void run() { 
     // Your code here 
     } 
} 

// Create and start the thread 
Thread thread = new BasicThread1(); 
thread.start();