/** * @author laishengfeng * @2014-8-27 * @TODO Write a program, Four threads, of which two threads each add 1, * to J each time a further two threads are reduced by 1 (requiring the use of an internal class thread) for each J */public class test{ public static void main (String[] args) { MyThread mt = new MyThread (); //mythread object mt.new innerthread1 (). Start (); mt.new InnerThread1 (). Start (); mt.new innerthread2 (). Start (); mt.new innerthread2 (). Start (); }}class mythread { private int j = 100; /* on the inner class of J-plus */ public class innerthread1 extends thread { public void run () { while (j < 120) { try { thread.sleep (+); }catch (exception&NBSP;EX) { } j++; system.out.println (Thread.CurrentThread (). GetName () + " " +j); } } } The inner class */ public class innerthread2 extends thread {of /* to J minus public void run () { while (j > 80) { try { thread.sleep (; ) }catch (Exception ex) { } j--; system.out.println (Thread.CurrentThread (). GetName () + " " +j); } } }}
Directly on the code is interested in mm I
Write a program, four threads, where two threads each add 1 to J, while the other two threads reduce the J each time by 1, requiring the use of internal classes