Javaflow

Apache
Java
跨平台
Apache
2012-04-17
红薯

Sometimes it is usefull if we can capture the state of the application, its stack of function calls, which includes local variables, the global variables and the program counter, and save them into an object. If this object would give us the ability to restart the processing from the point stored in it.

A continuation is exactly the type of object that we need. Think of a continuation as an object that, for a given point in your program, contains a snapshot of the stack trace, including all the local variables, and the program counter. You can not only store these things in the continuation object, but also restore the execution of the program from a continuation object. This means that the stack trace and the program counter of the running program become the ones stored in a continuation.

Continuations are powerful concepts from the world of functional languages, like Scheme, but they are becoming popular in other languages as well.

示例代码:

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());
System.out.println("returned a continuation");
加载中

评论(0)

暂无评论

暂无资讯

暂无问答

用ireport做报表的经验

20151127: 晚上下了本电子书,ireport开发详解,按他说的,官网下载了jaspereport-lib后,把disk目录下jar都拷贝到lib下,靠,不停的报错,根据报错依次在ireport下找到了对应的jar,commo...

2015/11/28 00:43
188
0
JAVA开源报表技术:JasperReports和iReport 实战

通过实例来学习报表技术

2014/08/26 13:03
352
0
Apache开源项目分类列表

分类 项目名 说明 开发语言 服务器 (共20) Apache HTTP Server 全球第一HTTP服务器 C/C++ Tomcat Java的Web服务器 Java James 邮件服务器 Java SpamAssassin 反垃圾邮件 C/C++ Perl Apach...

2009/05/08 00:19
2.3K
0
Apache java项目全介绍

Jakarta项目是ASF(The Apache Software Foundation)的一部分。 ASF是一个非赢利组织,她鼓励基于开放的软件许可下进行合作、注重实效的开发,并提供各个领域的高质量软件,她涉及到 Http服务...

2010/04/05 13:00
1K
1
Apache上全部JAVA开源项目简介

从网上转的,对于开源爱好者来说,Apache的这些东西很有必要了解...... Jakarta项目是ASF(The Apache Software Foundation)的一部分。ASF是一个非赢利组织,她鼓励基于开放的软件许可下进行合...

2013/11/12 10:46
284
0

没有更多内容

加载失败,请刷新页面

没有更多内容

返回顶部
顶部