Grosse MàJ
This commit is contained in:
6
workspace/Compteur/.classpath
Normal file
6
workspace/Compteur/.classpath
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path=""/>
|
||||
</classpath>
|
17
workspace/Compteur/.project
Normal file
17
workspace/Compteur/.project
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Compteur</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
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