
// HelloWorld.java
// Michele Loreti and the jSpace Developers, 2017 
// Andrew Davison, ad@coe.psu.ac.th, May 2023

/* Put a tuple into space, then get it back.
   A rather silly example, but a simple test that
   jSpace is working.

  Explained at:
    https://github.com/pSpaces/Programming-with-Spaces/blob/master/hello.md

  Usage:
    > compile.bat HelloWorld.java
    > run.bat HelloWorld

  Other versions: 
    * ConcurrentHelloWorld.java
    * RemoteHelloWorld.java
*/

import org.jspace.*;


public class HelloWorld
{
  public static void main(String[] args) 
                        throws InterruptedException
  {
    // choose one of these spaces
    Space inbox = new VisSpace();  
      /* to speed things up, add a delay argument to VisSpace
         (e.g. VisSpace(1000) for 1 second); the default is 2000 ms
      */
    // Space inbox = new SequentialSpace();

    // put then get data in the space
    inbox.put("Hello World");
    Object[] tuple = inbox.get(new FormalField(String.class));
    System.out.println(tuple[0]);
  } /* main */

} // end of HelloWorld class
