Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package assignment3;
- /**
- *
- * @author Zizo
- */
- public class Assignment3 {
- public static void main(String args[]) {
- Scanner sc = new Scanner(System.in);
- int[] inp = new int[5];
- for(int i = 0 ; i < 5 ; i++){
- System.out.println("how many time philosopher " + i + " will eat?\n");
- inp[i] = sc.nextInt();
- }
- Philosopher[] philosophers = new Philosopher[5];
- Monitor monitor = new Monitor();
- for (int i = 0; i < 5; i++) {
- philosophers[i] = new Philosopher(i, monitor, inp[i]);
- new Thread(philosophers[i]).start();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement