daily pastebin goal
93%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package FairSmokers;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import se.his.iit.it325g.common.AndrewsProcess;
  6. import se.his.iit.it325g.common.AsynchronousChan;
  7.  
  8. public class GlobalState {
  9.     private final static int numberOfTSmokers = 2;
  10.     private final static int numberOfPSmokers = 2;
  11.     private final static int numberOfMSmokers = 2;
  12.     //Sch0 = tobacco, Sch1 = paper, Sch2 = matches
  13.     public volatile static AsynchronousChan<Integer> Sch0 = new AsynchronousChan();
  14.     public volatile static AsynchronousChan<Integer> Sch1 = new AsynchronousChan();
  15.     public volatile static AsynchronousChan<Integer> Sch2 = new AsynchronousChan();
  16.     public volatile static AsynchronousChan<Integer> Ach4 = new AsynchronousChan();
  17.    
  18.     public static void main(String[] args) {
  19.        
  20.         ArrayList<AndrewsProcess> smokers = new ArrayList<>();
  21.        
  22.         AndrewsProcess agent = new AndrewsProcess(new Agent());
  23.         agent.start();
  24.        
  25.         for(int  i = 0; i < GlobalState.numberOfTSmokers; i++) {
  26.             AndrewsProcess smoker = new AndrewsProcess(new Smoker(0));
  27.             smoker.start();
  28.             smokers.add(smoker);
  29.         }
  30.         for(int  i = 0; i < GlobalState.numberOfPSmokers; i++) {
  31.             AndrewsProcess smoker = new AndrewsProcess(new Smoker(1));
  32.             smoker.start();
  33.             smokers.add(smoker);
  34.         }
  35.         for(int  i = 0; i < GlobalState.numberOfMSmokers; i++) {
  36.             AndrewsProcess smoker = new AndrewsProcess(new Smoker(2));
  37.             smoker.start();
  38.             smokers.add(smoker);
  39.         }
  40.     }
  41. }
RAW Paste Data
Top