Grosse MàJ
This commit is contained in:
BIN
workspace/Compteur/fr/blankoworld/compteur/Compteur.class
Normal file
BIN
workspace/Compteur/fr/blankoworld/compteur/Compteur.class
Normal file
Binary file not shown.
60
workspace/Compteur/fr/blankoworld/compteur/Compteur.java
Normal file
60
workspace/Compteur/fr/blankoworld/compteur/Compteur.java
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package fr.blankoworld.compteur;
|
||||
|
||||
/**
|
||||
* @author 3dossmanno
|
||||
*
|
||||
*/
|
||||
public class Compteur extends Thread{
|
||||
|
||||
private String nom;
|
||||
private int max;
|
||||
private int ordreArrivee;
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Compteur cpt;
|
||||
|
||||
if(args.length%2 == 0) {
|
||||
|
||||
for(int i = 0; i < args.length; i+=2)
|
||||
{
|
||||
cpt = new Compteur(args[i], Integer.parseInt(args[i+1]));
|
||||
cpt.start();
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Syntaxe: [Nom MAX]+");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Compteur(String name, int mx)
|
||||
{
|
||||
this.nom = name;
|
||||
this.max = mx;
|
||||
this.ordreArrivee = 0;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
for(int j = 1; j <= this.max; j++){
|
||||
this.ordreArrivee ++;
|
||||
try {
|
||||
sleep( (int)(Math.random()*5000) );
|
||||
} catch ( InterruptedException ex ) {
|
||||
}
|
||||
System.out.println(this.nom + ": " + this.ordreArrivee);
|
||||
}
|
||||
|
||||
System.out.println(this.nom + " a fini de compter jusqu'<27> " + this.max);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user