move demo documents into separate files

This commit is contained in:
Fabian Jakobs 2011-08-16 13:22:03 +02:00
commit 426259dc2f
23 changed files with 466 additions and 495 deletions

26
demo/docs/groovy.groovy Normal file
View file

@ -0,0 +1,26 @@
//http://groovy.codehaus.org/Concurrency+with+Groovy
import java.util.concurrent.atomic.AtomicInteger
def counter = new AtomicInteger()
synchronized out(message) {
println(message)
}
def th = Thread.start {
for( i in 1..8 ) {
sleep 30
out "thread loop $i"
counter.incrementAndGet()
}
}
for( j in 1..4 ) {
sleep 50
out "main loop $j"
counter.incrementAndGet()
}
th.join()
assert counter.get() == 12