2021-11-27 16:50:33 +00:00
|
|
|
package linda.test;
|
|
|
|
|
|
|
|
import linda.*;
|
|
|
|
|
|
|
|
public class BasicTest1 {
|
|
|
|
|
|
|
|
public static void main(String[] a) {
|
2021-11-27 19:24:42 +00:00
|
|
|
|
2021-11-27 16:50:33 +00:00
|
|
|
final Linda linda = new linda.shm.CentralizedLinda();
|
|
|
|
// final Linda linda = new linda.server.LindaClient("//localhost:4000/aaa");
|
2021-11-27 19:24:42 +00:00
|
|
|
|
2021-11-27 16:50:33 +00:00
|
|
|
new Thread() {
|
|
|
|
public void run() {
|
|
|
|
try {
|
|
|
|
Thread.sleep(2);
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
Tuple motif = new Tuple(Integer.class, String.class);
|
|
|
|
Tuple res = linda.take(motif);
|
|
|
|
System.out.println("(1) Resultat:" + res);
|
|
|
|
linda.debug("(1)");
|
|
|
|
}
|
|
|
|
}.start();
|
2021-11-27 19:24:42 +00:00
|
|
|
|
2021-11-27 16:50:33 +00:00
|
|
|
new Thread() {
|
|
|
|
public void run() {
|
|
|
|
try {
|
|
|
|
Thread.sleep(1000);
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
Tuple t1 = new Tuple(4, 5);
|
|
|
|
System.out.println("(2) write: " + t1);
|
|
|
|
linda.write(t1);
|
|
|
|
|
|
|
|
Tuple t11 = new Tuple(4, 5);
|
|
|
|
System.out.println("(2) write: " + t11);
|
|
|
|
linda.write(t11);
|
|
|
|
|
|
|
|
Tuple t2 = new Tuple("hello", 15);
|
|
|
|
System.out.println("(2) write: " + t2);
|
|
|
|
linda.write(t2);
|
|
|
|
|
|
|
|
Tuple t3 = new Tuple(4, "foo");
|
|
|
|
System.out.println("(2) write: " + t3);
|
|
|
|
linda.write(t3);
|
2021-11-27 19:24:42 +00:00
|
|
|
|
2021-11-27 16:50:33 +00:00
|
|
|
linda.debug("(2)");
|
|
|
|
|
|
|
|
}
|
|
|
|
}.start();
|
2021-11-27 19:24:42 +00:00
|
|
|
|
2021-11-27 16:50:33 +00:00
|
|
|
}
|
|
|
|
}
|