Skip to content

Instantly share code, notes, and snippets.

@jgranick
Created August 24, 2012 16:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgranick/3452819 to your computer and use it in GitHub Desktop.
Save jgranick/3452819 to your computer and use it in GitHub Desktop.
How to send messages to and from a thread (NME recipe)
import cpp.vm.Thread;
import nme.display.Sprite;
import nme.Lib;
class ThreadingExample extends Sprite {
public function new () {
super ();
var thread = Thread.create (onePlusOne);
thread.sendMessage (Thread.current ());
trace ("One plus one equals " + Thread.readMessage (true));
}
private function onePlusOne ():Void {
var main = Thread.readMessage (true);
main.sendMessage (1 + 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment