Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rewrite to use send/recv instead of put/get (+ add READMEs)
[simgrid.git] / examples / java / comm_time / Slave.java
1 /*
2  * $Id$
3  *
4  * Copyright 2006,2007 Martin Quinson, Malek Cherier         
5  * All rights reserved. 
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. 
9  */
10
11 import simgrid.msg.*;
12
13 public class Slave extends simgrid.msg.Process {
14    public void main(String[] args) throws JniException, NativeException {
15       if (args.length < 1) {
16          Msg.info("Slave needs 1 argument (its number)");
17          System.exit(1);
18       }
19
20       int num = Integer.valueOf(args[0]).intValue();
21       Msg.info("Receiving on 'slave_"+num+"'");
22       
23       while(true) { 
24          Task t = Task.receive("slave_"+num);   
25          
26          if (t instanceof FinalizeTask) {
27             break;
28          }
29          MyTask task = (MyTask)t;
30          task.execute();
31 //       Msg.info("\"" + task.getName() + "\" done ");
32        }
33        
34       Msg.info("Received Finalize. I'm done. See you!");
35     }
36 }