[groovy-user] Synchronized blocks working

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[groovy-user] Synchronized blocks working

Guillaume Laforge
Administrator
Hello,

I've just fixed a litte but very old bug with synchronized blocks in CVS Head.
They are now working and don't yield some nasty verifier errors.

As I'm not an ASM guru (and it did involved some bytecode generation
magic), I'd be grateful if some of you (those living on the edge with
CVS Head) could double check and try some synchronized(foo) samples of
your own creation, just to be sure it's really fixed.
Thanks in advance for that.

If you don't feel like building from sources, you might download a
snapshot of the upcoming JSR-04 release from there:
http://distci.codehaus.org/groovy/jars/
And drop that jar in replacement (yes, in replacement) of your old
JSR-03 jar of Groovy.

PS: For inspiration, my own little sample looked something like:

Integer foo = 1

Thread.start{
    println "sleeping for a moment"
    sleep 1000
    println "slept and synchronizing from thread"
    synchronized(foo) {
        println "notifying"
        foo.notify()
        println "notified"
    }
}

println "synchronizing"
synchronized(foo) {
    println "starting to wait"
    foo.wait()
    println "waited"
}
println "end"

--
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy