~ubuntu-branches/ubuntu/precise/jcsp/precise

« back to all changes in this revision

Viewing changes to src/jcsp-demos/doc-ex/jcsp/lang/ParallelTest.java

  • Committer: Bazaar Package Importer
  • Author(s): Miguel Landaeta
  • Date: 2010-06-20 18:12:26 UTC
  • Revision ID: james.westby@ubuntu.com-20100620181226-8yg8d9rjjjiuy7oz
Tags: upstream-1.1-rc4
ImportĀ upstreamĀ versionĀ 1.1-rc4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import org.jcsp.lang.*;
 
2
import org.jcsp.plugNplay.ints.*;
 
3
 
 
4
class ParallelTest {
 
5
 
 
6
  public static void main (String[] args) {
 
7
 
 
8
    final One2OneChannelInt[] a = Channel.one2oneIntArray (3);
 
9
    final One2OneChannel b = Channel.one2one ();
 
10
 
 
11
    new Parallel (
 
12
      new CSProcess[] {
 
13
        new NumbersInt (a[0].out ()),
 
14
        new SquaresInt (a[1].out ()),
 
15
        new FibonacciInt (a[2].out ()),
 
16
        new ParaplexInt (Channel.getInputArray (a), b.out ()),
 
17
        new CSProcess () {
 
18
          public void run () {
 
19
            System.out.println ("\n\t\tNumbers\t\tSquares\t\tFibonacci\n");
 
20
            while (true) {
 
21
              int[] data = (int[]) b.in ().read ();
 
22
              for (int i = 0; i < data.length; i++) {
 
23
                System.out.print ("\t\t" + data[i]);
 
24
              }
 
25
              System.out.println ();
 
26
            }
 
27
          }
 
28
        }
 
29
      }
 
30
    ).run ();
 
31
  }
 
32
 
 
33
}