Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
4b3e244453fb85f8ff399b9ce65afa7aafb87d5f
[simgrid.git] / examples / deprecated / java / async / dsend / Main.java
1 /* Copyright (c) 2006-2020. 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.dsend;
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 Sender(hosts[0],"Sender").start();
35     for (int i=1; i < hosts.length; i++){
36       new Receiver(hosts[i], "Receiver").start();
37     }
38     /*  execute the simulation. */
39     Msg.run();
40   }
41 }