X-Git-Url: https://git.llucax.com/z.facultad/75.59/filosofos.git/blobdiff_plain/463f5a807c033f58fe695db6c650bc006f2243d7..27b7c30ee95157607550495817109d20af55ece7:/src/filosofos3.java diff --git a/src/filosofos3.java b/src/filosofos3.java index 33d8fd1..68299de 100644 --- a/src/filosofos3.java +++ b/src/filosofos3.java @@ -80,7 +80,7 @@ class Filosofo extends Thread System.out.println ("Soy " + id + " y estoy comiendo por " + (new Integer(n)).toString ()); comidas_actuales++; try { - Thread.sleep (n); + Thread.sleep (n*1000); } catch (Exception e) {} finally {} } @@ -90,7 +90,7 @@ class Filosofo extends Thread int n = r.nextInt (5) + r.nextInt (2); System.out.println ("Soy " + id + " y estoy pensando por " + (new Integer(n)).toString ()); try { - Thread.sleep (n); + Thread.sleep (n*1000); } catch (Exception e) {} finally {} } @@ -116,13 +116,27 @@ public class filosofos3 { static public void main (String[] args) { - int n = 5; + int n; int i; + int cant; + + if (args.length < 2) { + /* Java parece no poner en args[0] el caller -.- .. Java Sucks :P */ + System.out.println ("Modo de uso: java filosofo3 "); + return; + } + n = Integer.parseInt (args[0]); + if (n < 2) { + System.out.println ("Debe haber por lo menos 2 chinos"); + return; + } + + cant = Integer.parseInt (args[1]); Palitos p = new Palitos (n); for (i=0; i