Professional Documents
Culture Documents
ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Semaphore;
/**
*
* @author ristes
*/
public class TancSoStudentite {
//TODO: Definicija na globalni promenlivi i semafori
Semaphore sala;
Semaphore garderobaMashki;
Semaphore garderobaZenski;
Semaphore tanc;
garderobaMashki.acquire();
show.presobleci();
garderobaMashki.release();
@Override
public void run() {
try {
ucestvo();
} catch (InterruptedException e) {
// Do nothing
} catch (Exception e) {
exception = e;
hasException = true;
}
}
@Override
public String toString() {
return String.format("m\t%d", getId());
}
public Exception exception = null;
}
garderobaZenski.acquire();
show.presobleci();
garderobaZenski.release();
tanc.release();
@Override
public void run() {
try {
ucestvo();
} catch (InterruptedException e) {
// Do nothing
} catch (Exception e) {
exception = e;
hasException = true;
}
}
@Override
public String toString() {
return String.format("z\t%d", getId());
}
public Exception exception = null;
}
public Show() {
}
public int brojMaskiGarderoba = 0;
public int brojZenskiGarderoba = 0;
public int brojTancuvanja = 0;
public int maxMaskiGarderoba = 0;
public int maxZenskiGarderoba = 0;
public int maxTancuvanja = 0;
} else {
System.out.println("Procesot ne e sinhroniziran spored uslovite na
zadacata");
show.printLog();
System.out.println("Maksimum mozni poeni: 15");
}
}
private List<String> actions = new ArrayList<String>();
private boolean hasError = false;
}
// Konstanti
public static int BROJ_INSTANCI = 1000;
public static final Random RANDOM = new Random();
public static final int RANDOM_RANGE = 3;
// Instanca od bafferot
public Show show;
public boolean hasException = false;
}