Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / examples / java / process / kill / Killer.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 process.kill;
8 import org.simgrid.msg.Msg;
9 import org.simgrid.msg.Process;
10 import org.simgrid.msg.MsgException;
11 import org.simgrid.msg.HostNotFoundException;
12
13 import process.kill.Victim;
14
15 public class Killer extends Process {
16   public Killer(String hostname, String name) throws HostNotFoundException {
17     super(hostname, name);
18   }
19   public void main(String[] args) throws MsgException {
20     Victim poorVictim = null;
21     Msg.info("Hello!");
22     try {
23       poorVictim = new Victim("Boivin","victim");
24       poorVictim.start();
25     } catch (MsgException e){
26       e.printStackTrace();
27       Msg.error("Cannot create the victim process!");
28     }
29     sleep(10000);
30     Msg.info("Resume Process");
31     if (poorVictim != null)
32       poorVictim.resume();
33     sleep(1000);
34     Msg.info("Kill Process");
35     if (poorVictim != null)
36       poorVictim.kill();
37
38     Msg.info("Ok, goodbye now.");
39   }
40 }