Advertisement
ahmad_zizo

Assignment3

May 25th, 2015
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package assignment3;
  7.  
  8. /**
  9.  *
  10.  * @author Zizo
  11.  */
  12. public class Assignment3 {
  13.  
  14.     public static void main(String args[]) {
  15.         Scanner sc = new Scanner(System.in);
  16.         int[] inp = new int[5];
  17.         for(int i = 0 ; i < 5 ; i++){
  18.             System.out.println("how many time philosopher " + i + " will eat?\n");
  19.             inp[i] = sc.nextInt();
  20.         }
  21.        
  22.         Philosopher[] philosophers = new Philosopher[5];
  23.         Monitor monitor = new Monitor();
  24.  
  25.         for (int i = 0; i < 5; i++) {
  26.             philosophers[i] = new Philosopher(i, monitor, inp[i]);
  27.             new Thread(philosophers[i]).start();
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement