|
@@ -5,11 +5,30 @@ class Main {
|
|
|
public static void main(String args[]){
|
|
|
System.out.println("Start thread lab");
|
|
|
|
|
|
- sharedMutex = new MutexTypeD();
|
|
|
+ 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 {
|
|
|
+ System.err.println("ERROR : unknown mutex type : " + args[0]);
|
|
|
+ showUsage();
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
runExperiment();
|
|
|
}
|
|
|
|
|
|
+ private static void showUsage() {
|
|
|
+ System.out.println("Usage : java Main <mutex_type>");
|
|
|
+ System.out.println("Where <mutex_type> is one of D|A|H|P");
|
|
|
+ }
|
|
|
+
|
|
|
private static void runExperiment() {
|
|
|
Task t0 = new Task("T0", 0, sharedMutex);
|
|
|
Task t1 = new Task("T1", 1, sharedMutex);
|