JActor - Actor模式的Java实现


LGPL
跨平台
Java

软件简介

JActor 是一个 Java 的 Actor 模式的实现,经过测试在 i5 CPU 上可支持每秒钟发送超过亿条消息,可能是目前最快的。这相当于是
Scala 的 Actor 的纯 Java 版本。

示例代码:

// Create a mailbox factory with a pool of 10 threads.
MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(10);

// Create and initialize a Test actor.
Mailbox mailbox = mailboxFactory.createAsyncMailbox();//.createMailbox();
MyActor actor = new MyActor();
actor.initialize(mailbox);

// Send a MyRequest request and wait for completion.
JAFuture future = new JAFuture();
long ct = System.currentTimeMillis();
System.out.println(MyRequest.req.send(future, actor));
// Shut down the thread pool.
mailboxFactory.close();