Back to project page androidcodes.
The source code is released under:
GNU General Public License
If you think the Android project androidcodes listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.java.thread; // ww w . ja va 2 s . com public class SampleThread { public static void main(String[] args) { Thread t2 = new Thread(new R2()); t2.start(); Thread t1 = new Thread(new R1()); t1.start(); } public static void runner() { for (int i = 0; i < 10; i++) { System.out.println("hello thread" + i); } } } class R2 implements Runnable { @Override public void run() { try { SampleThread.runner(); Thread.sleep(200); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } class R1 implements Runnable { @Override public void run() { try { SampleThread.runner(); Thread.sleep(200); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }