You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Safwan Khan <pe...@gmail.com> on 2012/04/18 02:04:50 UTC

[javaflow] How to compare two continuations?

I’m a very newbie in javaflow. Consider the following basic example:
class MyRunnable implements Runnable {
  public void run() {
    System.out.println("started!");
    for( int i=0; i<10; i++ )
      echo(i);
  }
  private void echo(int x) {
    System.out.println(x);
    Continuation.suspend();
  }
}

Continuation c = Continuation.startWith(new MyRunnable());
Continuation d = Continuation.continueWith(c);
Continuation e = Continuation.continueWith(d);
Continuation f = Continuation.continueWith(d);
if (e.equals(f)) System.out.println("They are equal!");
else System.out.println("They are not equal!");


Both continuation e and f starts with same check point (d) and captures the
same stacks and also both of them print 1. Then still why “They are not
equal!”? (program gives this output). Can someone please explain it to me?

Thanks,
Sainan

[javaflow] How to compare two continuations?

Posted by Sainan Khan <pe...@gmail.com>.
I’m a very newbie in javaflow. Consider the following basic example:
class MyRunnable implements Runnable {
  public void run() {
    System.out.println("started!");
    for( int i=0; i<10; i++ )
      echo(i);
  }
  private void echo(int x) {
    System.out.println(x);
    Continuation.suspend();
  }
}

Continuation c = Continuation.startWith(new MyRunnable());
Continuation d = Continuation.continueWith(c);
Continuation e = Continuation.continueWith(d);
Continuation f = Continuation.continueWith(d);
if (e.equals(f)) System.out.println("They are equal!");
else System.out.println("They are not equal!");


Both continuation e and f starts with same check point (d) and captures the
same stacks and also both of them print 1. Then still why “They are not
equal!”? (program gives this output). Can someone please explain it to me?

Thanks,
Sainan

Re: [javaflow] How to compare two continuations?

Posted by sebb <se...@gmail.com>.
On 18 April 2012 01:04, Safwan Khan <pe...@gmail.com> wrote:
> I’m a very newbie in javaflow.

Such questions belong on the Commons User list, not the developer list.
Please subscribe to it and ask there.

> Consider the following basic example:
> class MyRunnable implements Runnable {
>  public void run() {
>    System.out.println("started!");
>    for( int i=0; i<10; i++ )
>      echo(i);
>  }
>  private void echo(int x) {
>    System.out.println(x);
>    Continuation.suspend();
>  }
> }
>
> Continuation c = Continuation.startWith(new MyRunnable());
> Continuation d = Continuation.continueWith(c);
> Continuation e = Continuation.continueWith(d);
> Continuation f = Continuation.continueWith(d);
> if (e.equals(f)) System.out.println("They are equal!");
> else System.out.println("They are not equal!");
>
>
> Both continuation e and f starts with same check point (d) and captures the
> same stacks and also both of them print 1. Then still why “They are not
> equal!”? (program gives this output). Can someone please explain it to me?
>
> Thanks,
> Sainan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org