Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
spelling mistakes in include/ and examples/
[simgrid.git] / examples / deprecated / java / async / waitall / 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.waitall;
7
8 /** This example demonstrates the use of the asynchronous communications
9  * 
10  *  Task.isend() and Task.irecv() are used to start the communications in non-blocking mode.
11  *  
12  *  The sends are then blocked onto with Comm.waitCompletion(), that locks until the given 
13  *  communication terminates.
14  *  
15  *  The receives are packed into an array, and the sender blocks until all of them terminate 
16  *  with Comm.waitAll().
17  */
18
19
20 import org.simgrid.msg.Msg;
21 import org.simgrid.msg.Host;
22
23 class Main {
24   private Main() {
25     throw new IllegalAccessError("Utility class");
26   }
27
28   public static void main(String[] args) {
29     Msg.init(args);
30
31     String platform = "../platforms/small_platform.xml";
32     if (args.length >= 1) {
33         platform = args[0]; // Override the default value if passed on the command line
34     }
35
36     /* construct the platform and deploy the application */
37     Msg.createEnvironment(platform);
38     Host[] hosts = Host.all();
39     new Sender(hosts[0],"Sender").start();
40     for (int i=1; i < hosts.length; i++){
41       new Receiver(hosts[i], "Receiver").start();
42     }
43     /*  execute the simulation. */
44     Msg.run();
45   }
46 }