Design four threads. Two threads increase 1 for j each time, and the other two threads decrease 1 for j each time. Write the program 100 times in a loop.
Package cn. usst. DataTest6;/*** four threads are designed. Two threads increase 1 to j each time, and the other two threads decrease 1 to j each time. Write the program 100 times in a loop. * @ **/Public class DataTest6 {private int j; public static void main (String [] args) {DataTest6 dt = new DataTest6 (); Inc inc = dt. new Inc (); Dec = dt. new Dec (); for (int I = 0; I <2; I ++) {Thread t = new Thread (inc); t. start (); t = new Thread (dec); t. start () ;}} class Inc implements Runnable {public void run () {for (int I = 0; I <100; I ++) {inc ();}}} class Dec implements Runnable {public void run () {for (int I = 0; I <100; I ++) {dec () ;}} private synchronized void inc () {j ++; System. out. println (Thread. currentThread (). getName () + "+ inc:" + j);} private synchronized void dec () {j --; System. out. println (Thread. currentThread (). getName () + "-dec:" + j );}}