class Main { static Mutex sharedMutex; public static void main(String args[]){ System.out.println("Start thread lab"); if (args.length != 1) { System.err.println("ERROR : incorrect argument."); showUsage(); return; } if (args[0].equals("D")) sharedMutex = new MutexTypeD(); else if (args[0].equals("H")) sharedMutex = new MutexTypeH(); else if (args[0].equals("N")) sharedMutex = new MutexTypeN(); else { System.err.println("ERROR : unknown mutex type : " + args[0]); showUsage(); return; } runExperiment(); } private static void showUsage() { System.out.println("Usage : java Main "); System.out.println("Where is one of N|D|A|H|P"); } private static void runExperiment() { Task t0 = new Task("T0", 0, sharedMutex); Task t1 = new Task("T1", 1, sharedMutex); t0.describe(); t1.describe(); sharedMutex.describe(); t0.start(); t1.start(); } }