From: Roedy Green on 24 Mar 2010 18:11 The IntelliJ code Inspector (lint) slapped my wrist for synchronising on a local variable. What's the problem with that? The sync is on the object, not the reference, right? -- Roedy Green Canadian Mind Products http://mindprod.com Don�t worry about people stealing an idea; if it�s original, you�ll have to shove it down their throats. ~ Howard Aiken (born: 1900-03-08 died: 1973-03-14 at age: 73)
From: markspace on 24 Mar 2010 18:19 Roedy Green wrote: > The IntelliJ code Inspector (lint) slapped my wrist for synchronising > on a local variable. What's the problem with that? The sync is on > the object, not the reference, right? Need SSCCE. http://sscce.org/
From: Arved Sandstrom on 24 Mar 2010 18:46 Roedy Green wrote: > The IntelliJ code Inspector (lint) slapped my wrist for synchronising > on a local variable. What's the problem with that? The sync is on > the object, not the reference, right? Each thread gets its own local variable. Defeats the purpose of synchronizing on one. AHS
From: markspace on 24 Mar 2010 18:55 Arved Sandstrom wrote: > Roedy Green wrote: >> The IntelliJ code Inspector (lint) slapped my wrist for synchronising >> on a local variable. What's the problem with that? The sync is on >> the object, not the reference, right? > > Each thread gets its own local variable. Defeats the purpose of > synchronizing on one. If you later export that local reference to another thread or object, it should be fine. It's valid to synchronize on a object that some other part of the system will see later. If you just synchronized on a local variable and then let it go out of scope, yeah, that's a pretty serious "D'oh!" moment.
From: Arne Vajhøj on 24 Mar 2010 19:09 On 24-03-2010 18:11, Roedy Green wrote: > The IntelliJ code Inspector (lint) slapped my wrist for synchronising > on a local variable. What's the problem with that? The sync is on > the object, not the reference, right? Local variables are thread specific. Passing on a local variable to another thread via some global variable/singleton/cache would be a pretty bad design. I can understand the complaint. Arne PS: yes - it is the object not the ref.
|
Next
|
Last
Pages: 1 2 3 4 5 6 7 Prev: web service behind firewall without DNS Next: java plugin for linux firefox 3.6 |