Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
java: kill obscure NativeException
[simgrid.git] / examples / java / async / yield / Main.java
1 /* Copyright (c) 2017. 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 async.yield;
7
8 /** This example demonstrates the use of the Task.dsend() method.
9  * 
10  *  This way, the sender can be detached from the communication: it is not blocked as with Task.send() 
11  *  and has nothing to do at the end as with Task.isend() where it must do a Comm.wait().
12  */
13
14 import org.simgrid.msg.Host;
15 import org.simgrid.msg.HostNotFoundException;
16 import org.simgrid.msg.Msg;
17
18 class Main {
19   private Main() {
20         /* This is just to ensure that nobody creates an instance of this singleton */
21     throw new IllegalAccessError("Utility class");
22   }
23
24   public static void main(String[] args) throws HostNotFoundException {
25     Msg.init(args);
26
27     String platform = "../platforms/small_platform.xml";
28     if (args.length >= 1) {
29         platform = args[0]; // Override the default value if passed on the command line
30     }
31
32     /* construct the platform and deploy the application */
33     Msg.createEnvironment(platform);
34     Host[] hosts = Host.all();
35     new Yielder(hosts[0],"Yielder", new String[] {"10"}).start();
36     new Yielder(hosts[1],"Yielder", new String[] {"15"}).start();
37     
38     /*  execute the simulation. */
39     Msg.run();
40   }
41 }