[Thread] Synchronisation de thread
Bonjour
Voici mon problème. Dans une fonction, je crée un thread. Pour le moment, ce thread ne s'occupe que d'afficher un message :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
private void launchBlast() throws IOException{
System.out.println("Blasting...");
Thread t = new Thread(){
public void run(){
String cmd = "ssh gldavid@cluster blastall -p blastn -d "+db+" -i "+inputfile+" -m 7 -o "+outputfile;
System.out.println(""+cmd);
//Runtime.getRuntime().exec(cmd);
}
};
t.start();
}
/**
* @param args
*/
public static void main(String[] args) throws IOException {
JBlast jBlast = new JBlast();
jBlast.verifyArgs(args);
jBlast.launchBlast();
System.out.println("Finished the blast");
} |
Or, avec ce code, je remarque l'affichage suivant à l'exécution :
Code:
1 2 3 4
|
Blasting...
Finished the blast
ssh gldavid@cluster blastall -p blastn -d /bioxpr/cluster/databases/blast/refseq/Homo_sapiens/refseq_Homo_sapiens_rna -i /home/gldavid/seq.txt -m 7 -o /home/gldavid/results.xml |
Donc, le thread est exécuté après ma fonction 8O
J'eus plutôt souhaité avoir le message de mon thread avant la fin de ma fonction.
Comment résoudre donc ce problème ?
Merci d'avance de votre aide.
@++