File tree Expand file tree Collapse file tree 1 file changed +33
-2
lines changed
Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change 11actor
22=====
33
4- A one file java actor library.
4+ A minimal java actor library.
55
6- This is a simplified version of < https://github.com/edescourtis/actor >
6+ package com.benbria.actor;
7+
8+ public class ActorExample {
9+ public static void main(String[] args) throws InterruptedException {
10+ Actor<String> actor = Actor.createAndStart(new Actor.Behavior<String>()
11+ @Override
12+ public boolean onReceive(Actor<String> self, String msg) {
13+ System.out.println("Got: " + msg);
14+ return !msg.equals("stop");
15+ }
16+
17+ @Override
18+ public void exception(Actor<String> self, Exception e) {}
19+ });
20+
21+ actor.send("hello");
22+ actor.send("world");
23+ Thread.sleep(1000);
24+ actor.send("stop");
25+ }
26+ }
27+
28+ Output:
29+ <pre >
30+ Got: hello
31+ Got: world
32+ </pre >
33+
34+ License
35+ -
36+
37+ MIT
You can’t perform that action at this time.
0 commit comments