import java.util.concurrent.locks.*; public class SynchronizedVsFairLock { public static void main(String args[]) throws InterruptedException { System.out.println("Environment:"); System.out.println("java.runtime.name = "+System.getProperty("java.runtime.name")); System.out.println("java.runtime.version = "+System.getProperty("java.runtime.version")); System.out.println("java.vendor = "+System.getProperty("java.vendor")); System.out.println("java.version = "+System.getProperty("java.version")); System.out.println("java.vm.name = "+System.getProperty("java.vm.name")); System.out.println("java.vm.info = "+System.getProperty("java.vm.info")); System.out.println("os.name = "+System.getProperty("os.name")); System.out.println("os.version = "+System.getProperty("os.version")); System.out.println("os.arch = "+System.getProperty("os.arch")); System.out.println("##########################################"); usingSynchronized(10); usingUnfairLock(10); usingFairLock(10); } public static void execute(String text, Thread[] threads) throws InterruptedException { System.out.println("About to execute "+text+"..."); int threadCount=threads.length; for(int i=0;i