Skip to content

Instantly share code, notes, and snippets.

@aya-eiya
Created July 15, 2011 11:46
Show Gist options
  • Save aya-eiya/1084542 to your computer and use it in GitHub Desktop.
Save aya-eiya/1084542 to your computer and use it in GitHub Desktop.
GPARS Practice
/***************************
* GPARS Practice @aya_eiya *
****************************/
import static groovyx.gpars.actor.Actors.actor
def d1 = new Date()
def decryptor = actor {
loop {
react { message->
if(message){
for(i in 0 ..< 100 ){
println "d:$i"
sleep(25)
}
reply 'done'
}else{
stop()
}
}
}
}
def console = actor {
decryptor.send(true)
for(i in 0 ..< 100 ){
println "c:$i"
sleep(50)
}
loop{
react {
if(new Date().time - d1.time > 5350){
decryptor.send(false)
println 'stopped'
stop()
}else{
decryptor.send(true)
}
}
}
}
[decryptor, console]*.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment