Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
c90ad64b685eeb901a20b6cf138cb56709a0e643
[simgrid.git] / examples / java / commTime / Slave.java
1 /* Copyright (c) 2006-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 package commTime;
8
9 import org.simgrid.msg.*;
10
11 public class Slave extends org.simgrid.msg.Process {
12         public Slave(Host host, String name, String[]args) {
13                 super(host,name,args);
14         } 
15         public void main(String[] args) throws MsgException {
16       if (args.length < 1) {
17          Msg.info("Slave needs 1 argument (its number)");
18          System.exit(1);
19       }
20
21       int num = Integer.valueOf(args[0]).intValue();
22       Msg.info("Receiving on 'slave_"+num+"'");
23       
24       while(true) { 
25          Task task = Task.receive("slave_"+num);        
26          
27          if (task instanceof FinalizeTask) {
28             break;
29          }
30          task.execute();
31        }
32        
33       Msg.info("Received Finalize. I'm done. See you!");
34     }
35 }