文件名称:Actor模式的Java实现JActor.zip
文件大小:235KB
文件格式:ZIP
更新时间:2022-08-05 23:48:44
开源项目
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(); 标签:JActor