Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
4249fdb0195389013fb4aee37a980f065aa07a7f
[simgrid.git] / examples / java / basic / Slave.java
1 /*
2  * Copyright 2006,2007,2010. The SimGrid Team. 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
8 import simgrid.msg.*;
9
10 public class Slave extends simgrid.msg.Process {
11    public void main(String[] args) throws NativeException {
12       if (args.length < 1) {
13          Msg.info("Slave needs 1 argument (its number)");
14          System.exit(1);
15       }
16
17       int num = Integer.valueOf(args[0]).intValue();
18       Msg.info("Receiving on 'slave_"+num+"'");
19       
20       while(true) { 
21          Task task = Task.receive("slave_"+num);        
22          
23          if (task instanceof FinalizeTask) {
24             break;
25          }
26          Msg.info("Received \"" + task.getName() +  "\". Processing it.");       
27          task.execute();
28          Msg.info("\"" + task.getName() + "\" done ");
29        }
30        
31       Msg.info("Received Finalize. I'm done. See you!");
32     }
33 }