Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
e03b69c2bcbe24fd09aab3a8f9be72e932d2e48a
[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       return;
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 }