coarse-grained locking in java