Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
b813700237c6434a5dbd4a4c7dd3b02a042b6fc8
[simgrid.git] / examples / deprecated / java / process / kill / Killer.java
1 /* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 package process.kill;
7 import org.simgrid.msg.Msg;
8 import org.simgrid.msg.Process;
9 import org.simgrid.msg.MsgException;
10 import org.simgrid.msg.HostNotFoundException;
11
12 public class Killer extends Process {
13   public Killer(String hostname, String name) throws HostNotFoundException {
14     super(hostname, name);
15   }
16   public void main(String[] args) throws MsgException {
17     Victim poorVictim = null;
18     Msg.info("Hello!");
19     try {
20       poorVictim = new Victim("Boivin","victim");
21       poorVictim.start();
22     } catch (MsgException e){
23       e.printStackTrace();
24       Msg.error("Cannot create the victim process!");
25       return;
26     }
27     sleep(10000);
28     Msg.info("Resume Process");
29     poorVictim.resume();
30     sleep(1000);
31     Msg.info("Kill Process");
32     poorVictim.kill();
33
34     Msg.info("Ok, goodbye now.");
35     // The actor can also commit a suicide with the following command
36     exit(); // This will forcefully stop the current actor
37     // Of course, it's not useful here at the end of the main function, but that's for the example (and to check that this still works in the automated tests)
38   }
39 }