Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Added example
  • Loading branch information
edescourtis authored Mar 9, 2017
1 parent 754c93b commit 64b23e7
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
actor
=====

A one file java actor library.
A minimal java actor library.

This is a simplified version of <https://github.com/edescourtis/actor>
package com.benbria.actor;

public class ActorExample {
public static void main(String[] args) throws InterruptedException {
Actor<String> actor = Actor.createAndStart(new Actor.Behavior<String>()
@Override
public boolean onReceive(Actor<String> self, String msg) {
System.out.println("Got: " + msg);
return !msg.equals("stop");
}

@Override
public void exception(Actor<String> self, Exception e) {}
});

actor.send("hello");
actor.send("world");
Thread.sleep(1000);
actor.send("stop");
}
}

Output:
<pre>
Got: hello
Got: world
</pre>

License
-

MIT

0 comments on commit 64b23e7

Please sign in to comment.