Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #6391
| 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, 21 Jul 2011 23:08:07 -0500 |
| Date | Thu, 21 Jul 2011 21:08:05 -0700 |
| From | Patricia Shanahan <pats@acm.org> |
| User-Agent | Mozilla/5.0 (Windows NT 5.2; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 |
| MIME-Version | 1.0 |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Why "lock" functionality is introduced for all the objects? |
| References | <d0bb9e06-16f0-4282-a37e-47e9ca9630ec@r2g2000vbj.googlegroups.com> <4e28c54c$0$308$14726298@news.sunsite.dk> |
| In-Reply-To | <4e28c54c$0$308$14726298@news.sunsite.dk> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 8bit |
| Message-ID | <aPydnWItsNg6arXTnZ2dnUVZ_qydnZ2d@earthlink.com> (permalink) |
| Lines | 29 |
| X-Usenet-Provider | http://www.giganews.com |
| NNTP-Posting-Host | 70.230.200.239 |
| X-Trace | sv3-zWG3GP/6yTD0kJyerqrcpuZAVrEVJsbjYv/ocE+CI/mXphdEU2xOHqQatXwgCECPMSPf6rFCnKrcbAy!7QutKE6vLty/lfMSt3MLCJGumx/lXbnRLLDFazpODiMPX5sKXhs7eWyvOtkKnKp9vu/rLJfKP8Ak!OLBKV5dtqNwZV+U4yzQZJYl534wNCE59QHx+avAV/au6wNY= |
| 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 | 1924 |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6391 |
Show key headers only | View raw
On 7/21/2011 5:33 PM, Arne Vajhøj wrote:
...
> For all the simple cases:
>
> public class Foobar {
> ...
> private Object lock = new Object();
> ...
> public void test() {
> ...
> synchronized(lock) {
> ...
> }
> ...
> }
> ...
> }
>
> having to use LockingObject instead of Object would have worked fine.
>
> But in more complex scenarios where you have multiple methods modifying
> multiple objects, then the only safe way is to lock on the actual
> objects (obviously in a fixed order to avoid deadlocks).
I'm not sure how that would have worked for synchronized methods, as
distinct from synchronized blocks.
Patricia
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Re: Why "lock" functionality is introduced for all the objects? Arne Vajhøj <arne@vajhoej.dk> - 2011-07-21 20:33 -0400
Re: Why "lock" functionality is introduced for all the objects? Patricia Shanahan <pats@acm.org> - 2011-07-21 21:08 -0700
Re: Why "lock" functionality is introduced for all the objects? Arne Vajhøj <arne@vajhoej.dk> - 2011-07-22 10:20 -0400
csiph-web