标签:callback new cti private back aging except cal while
package test; import java.awt.List; import java.awt.image.AreaAveragingScaleFilter; import java.lang.reflect.Array; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.io.BufferedInputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Reader; import java.io.Writer; import javax.security.auth.callback.LanguageCallback; import javax.swing.text.StyledEditorKit.BoldAction; class Lock { public static final Object alock = new Object(); public static final Object block = new Object(); } class Zhuzhu implements Runnable { public String c; private boolean flag; private int num = 100; public Zhuzhu(boolean flag) { this.flag = flag; } Object object = new Object(); public void run() { if (flag == true) { while(true) synchronized (Lock.alock) { System.out.println("if...alock"); synchronized (Lock.block) { System.out.println("if....block"); } } } else { while(true) synchronized (Lock.block) { System.out.println("else...block"); synchronized (Lock.alock) { System.out.println("else....alock"); } } } } } public class Main { public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(new BufferedInputStream(System.in)); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); Zhuzhu c = new Zhuzhu(true); Zhuzhu d = new Zhuzhu(false); Thread t1 = new Thread(c); Thread t2 = new Thread(d); t1.start(); t2.start(); } }
标签:callback new cti private back aging except cal while
原文地址:https://www.cnblogs.com/WINDZLY/p/11788619.html