Created
August 24, 2012 16:52
-
-
Save jgranick/3452819 to your computer and use it in GitHub Desktop.
How to send messages to and from a thread (NME recipe)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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