Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
08bd9b63860b855a380160aae5bd84aeff359445
[simgrid.git] / examples / java / kill / Killer.java
1 /* Master of a basic master/slave example in Java */
2
3 /* Copyright (c) 2006-2014. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 package kill;
10 import org.simgrid.msg.Msg;
11 import org.simgrid.msg.Process;
12 import org.simgrid.msg.MsgException;
13 import org.simgrid.msg.HostNotFoundException;
14
15 import kill.Victim;
16
17 public class Killer extends Process {
18   public Killer(String hostname, String name) throws HostNotFoundException {
19     super(hostname, name);
20   }
21   public void main(String[] args) throws MsgException {
22     Victim poorVictim = null;
23     Msg.info("Hello!");
24     try {
25       poorVictim = new Victim("Boivin","victim");
26       poorVictim.start();
27     } catch (MsgException e){
28       System.out.println("Cannot create the victim process!");
29     }
30     sleep(10000);
31     Msg.info("Resume Process");
32     poorVictim.resume();
33     sleep(1000);
34     Msg.info("Kill Process");
35     poorVictim.kill();
36
37     Msg.info("Ok, goodbye now.");
38   }
39 }