Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package FairSmokers;
- import java.util.ArrayList;
- import se.his.iit.it325g.common.AndrewsProcess;
- import se.his.iit.it325g.common.AsynchronousChan;
- public class GlobalState {
- private final static int numberOfTSmokers = 2;
- private final static int numberOfPSmokers = 2;
- private final static int numberOfMSmokers = 2;
- //Sch0 = tobacco, Sch1 = paper, Sch2 = matches
- public volatile static AsynchronousChan<Integer> Sch0 = new AsynchronousChan();
- public volatile static AsynchronousChan<Integer> Sch1 = new AsynchronousChan();
- public volatile static AsynchronousChan<Integer> Sch2 = new AsynchronousChan();
- public volatile static AsynchronousChan<Integer> Ach4 = new AsynchronousChan();
- public static void main(String[] args) {
- ArrayList<AndrewsProcess> smokers = new ArrayList<>();
- AndrewsProcess agent = new AndrewsProcess(new Agent());
- agent.start();
- for(int i = 0; i < GlobalState.numberOfTSmokers; i++) {
- AndrewsProcess smoker = new AndrewsProcess(new Smoker(0));
- smoker.start();
- smokers.add(smoker);
- }
- for(int i = 0; i < GlobalState.numberOfPSmokers; i++) {
- AndrewsProcess smoker = new AndrewsProcess(new Smoker(1));
- smoker.start();
- smokers.add(smoker);
- }
- for(int i = 0; i < GlobalState.numberOfMSmokers; i++) {
- AndrewsProcess smoker = new AndrewsProcess(new Smoker(2));
- smoker.start();
- smokers.add(smoker);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement