public class AndroidsCastleActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); (new Thread(new Runnable() { @Override public void run() { while(true){ Log.d("test","thread"); try { Thread.sleep(1000); } catch (InterruptedException e) {} } } })).start(); } }
public class AndroidsCastleActivity extends Activity implements Runnable { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); (new Thread(this)).start(); } @Override public void run() { while(true){ Log.d("test","thread"); try { Thread.sleep(1000); } catch (InterruptedException e) {} } } }
public class AndroidsCastleActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); (new Thread(new myThread())).start(); } class myThread implements Runnable { @Override public void run() { while (true) { Log.d("test", "thread"); try { Thread.sleep(1000); } catch (InterruptedException e) {} } } } }
Portions of this page are modifications
based on work created and shared by Google and used according to terms
described in the Creative Commons 3.0 Attribution License.
- Remical Soft -