Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
The java examples to illustrate the usage of the mailbox concept.
[simgrid.git] / examples / java / alias1 / Slave.java
1 /*\r
2  * $Id: Slave.java 5059 2007-11-19 20:01:59Z mquinson $\r
3  *\r
4  * Copyright 2006,2007 Martin Quinson, Malek Cherier         \r
5  * All rights reserved. \r
6  *\r
7  * This program is free software; you can redistribute it and/or modify it\r
8  * under the terms of the license (GNU LGPL) which comes with this package. \r
9  */\r
10 \r
11 import simgrid.msg.*;\r
12 \r
13 public class Slave extends simgrid.msg.Process \r
14 {\r
15         public void main(String[] args) throws JniException, NativeException \r
16         {\r
17                 Msg.info("Hello !");\r
18                 \r
19                 while(true) \r
20                 { \r
21                         Task t = Task.receive(Host.currentHost().getName());    \r
22                 \r
23                         if (t instanceof FinalizeTask) \r
24                         {\r
25                                 break;\r
26                         }\r
27                         \r
28                         BasicTask task = (BasicTask)t;\r
29                         Msg.info("Received \"" + task.getName() + "\" ");\r
30                 \r
31                         Msg.info("Processing \"" + task.getName() +  "\" ");     \r
32                         task.execute();\r
33                         Msg.info("\"" + task.getName() + "\" done ");\r
34                 }\r
35                 \r
36                 Msg.info("Received Finalize. I'm done. See you!");\r
37         }\r
38 }