Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 30 Jun 2011 19:05:23 -0500 Date: Thu, 30 Jun 2011 17:05:12 -0700 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Why "lock" functionality is introduced for all the objects? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 21 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 70.230.196.78 X-Trace: sv3-OoeBJzpALqnGskmq9weASsdJXPTBZCpR8Evv578EVtssxV2zgRIha+8Pwyfah5CUQdbLg9D1aQrzobq!KU1TFPf2gH4TxYcdpCvffN7c1fTYhFgZDaLAIWggkjNrQ7qG4Bz7gTmmZdJFNfO187CGU6YyobAj!R++WLpYatjL9GE4wvCgydTqrz0AMkE3TaH1FvYk4Y+bmYA== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2331 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5803 On 6/30/2011 3:29 PM, KitKat wrote: > On 30/06/2011 6:04 PM, Tom Anderson wrote: ... >> The details are described quite clearly in the papers, but the upshot is >> that an object is created with neither a lock nor a slot for a lock >> pointer (and so only a two-word header), and the lock is allocated only >> when needed, and then wired in. Some fancy footwork means that the >> object doesn't need to grow a pointer when this happens; the header >> remains two words, at the expense of some slight awkwardness elsewhere. > > Such as? I can think of only one possibility that could be even close to > efficient: maintain an IdentityHashMap somewhere under the > hood. The obvious alternative is the make one of the existing words dual purpose, either directly containing its data or containing an index to a structure containing both the lock and the original use of the word. That does require, in effect, a spare bit to indicate which mode the object is in. Patricia