Skip to content

Commit 64b23e7

Browse files
authored
Update README.md
Added example
1 parent 754c93b commit 64b23e7

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

README.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
11
actor
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

0 commit comments

Comments
 (0)