Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into fix/execute_benched
[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.Msg;
16
17 class Main {
18   private Main() {
19         /* This is just to ensure that nobody creates an instance of this singleton */
20     throw new IllegalAccessError("Utility class");
21   }
22
23   public static void main(String[] args) {
24     Msg.init(args);
25
26     String platform = "../platforms/small_platform.xml";
27     if (args.length >= 1) {
28         platform = args[0]; // Override the default value if passed on the command line
29     }
30
31     /* construct the platform and deploy the application */
32     Msg.createEnvironment(platform);
33     Host[] hosts = Host.all();
34     new Yielder(hosts[0],"Yielder", new String[] {"10"}).start();
35     new Yielder(hosts[1],"Yielder", new String[] {"15"}).start();
36     
37     /*  execute the simulation. */
38     Msg.run();
39   }
40 }