• Bug
  • Status: Resolved
  • 2 Major
  • Resolution: Won't Fix
  • Byte Code Transform
  • interfaces
  • Reporter: teck
  • April 23, 2008
  • 0
  • Watchers: 1
  • February 12, 2014
  • February 12, 2014

Description

It isn’t well known, but autolocking a method that does something like:

String s = “bob”; syncrhonized(s) { // }

will obtain dso lock based on the value (not the identity) of the String. It doesn’t matter if the String instance has been referred to by a shared object or not. This feature is known as literal autolocks.

The suprising thing (provided literal autolocks aren’t surprising enough) is that wait/notify() on the String instance does not do anything (it is local only)

Comments

Taylor Gautier 2008-04-23

Yeah thanks tim. I forgot about this feature. Nice. We need to make a corollary doc bug to make sure this gets documented.

Hung Huynh 2014-02-12

DSO is discontinued