changed synchronized from extension method to normal one

This commit is contained in:
Alex Tkachman
2012-01-24 14:48:09 +02:00
parent e61a9f62ba
commit 8176487c93
5 changed files with 9 additions and 10 deletions
@@ -11,16 +11,16 @@ fun thread(block: ()->Unit ) {
}
fun box() : String {
val ref = AtomicInteger()
val mtref = AtomicInteger()
val cdl = CountDownLatch(11)
for(i in 0..10) {
thread {
var current = 0
do {
current = ref.synchronized {
val v = ref.get() + 1
current = synchronized(mtref) {
val v = mtref.get() + 1
if(v < 100)
ref.set(v+1)
mtref.set(v+1)
v
}
}
@@ -29,5 +29,5 @@ fun box() : String {
}
}
cdl.await()
return if(ref.get() == 100) "OK" else ref.get().toString()
return if(mtref.get() == 100) "OK" else mtref.get().toString()
}