Sfoglia il codice sorgente

Differentiate processus markers

DricomDragon 5 anni fa
parent
commit
59320cfbbb
2 ha cambiato i file con 3 aggiunte e 3 eliminazioni
  1. 1 1
      ta1/Mutex.java
  2. 2 2
      ta1/Task.java

+ 1 - 1
ta1/Mutex.java

@@ -2,7 +2,7 @@ import java.util.concurrent.ThreadLocalRandom;
 
 public abstract class Mutex {
 
-	public static void criticalSection(char mark) {
+	public static void criticalSection(String mark) {
 		try {
 			int maxIter = 10;
 			int minIter = 1;

+ 2 - 2
ta1/Task.java

@@ -20,11 +20,11 @@ class Task extends Thread {
 			critical.p(id);
 
 			System.out.println( name + " is CRITICAL!");
-			Mutex.criticalSection('|');
+			Mutex.criticalSection(((Integer)id).toString());
 
 			critical.v(id);
 
-			System.out.println( name + " non critical.");
+			System.out.println( name + " isn't critical anymore.");
 			Mutex.nonCriticalSection();
 		}
 	}