Prev: inheriting a main method
Next: Adding int to a float
From: Arved Sandstrom on 16 Sep 2009 05:08 In article <h8q2li$6tm$4(a)news.eternal-september.org>, Dave Searles <searles(a)hoombah.nurt.bt.uk> wrote: > Arne Vajh�j wrote: > > It is a deal - the compiler does not give you hints about how > > to write code > > Sure it does; they're called "warnings". [ SNIP ] And flat-out in your face errors. :-) AHS
From: Scott A. Hightower on 16 Sep 2009 06:17 "Dave Searles" <searles(a)hoombah.nurt.bt.uk> wrote in message news:h8q2bu$6tm$3(a)news.eternal-september.org... > markspace wrote: >> rossum wrote: >>> >>> I am talking about local variables, not member variables. >> >> I was just re-reading in Java Concurrency in Practice that some modifiers >> are important, because the JIT/javac will hoist variables out of loops: >> >> volatile boolean done = false; >> >> while(!done) >> processData(); >> >> "done" will be hoist out of the loop with out the volatile modifier, >> resulting in an infinite loop. > > Since that loop cannot set "done" the loop is infinite anyway (barring an > uncaught exception or System.exit() call beneath processData() somewhere). volatile
From: Dave Searles on 16 Sep 2009 07:02 Arved Sandstrom wrote: > In article <h8q2li$6tm$4(a)news.eternal-september.org>, Dave Searles > <searles(a)hoombah.nurt.bt.uk> wrote: > >> Arne Vajh�j wrote: >>> It is a deal - the compiler does not give you hints about how >>> to write code >> Sure it does; they're called "warnings". > [ SNIP ] > > And flat-out in your face errors. :-) I wouldn't call outright errors "hints". :)
From: rossum on 16 Sep 2009 10:37 On Wed, 16 Sep 2009 07:02:05 -0400, Dave Searles <searles(a)hoombah.nurt.bt.uk> wrote: >Arved Sandstrom wrote: >> In article <h8q2li$6tm$4(a)news.eternal-september.org>, Dave Searles >> <searles(a)hoombah.nurt.bt.uk> wrote: >> >>> Arne Vajhøj wrote: >>>> It is a deal - the compiler does not give you hints about how >>>> to write code >>> Sure it does; they're called "warnings". >> [ SNIP ] >> >> And flat-out in your face errors. :-) > >I wouldn't call outright errors "hints". :) Only in the sense that being beaten about the head with a blunt object is a 'hint'. rossum
From: Roedy Green on 16 Sep 2009 11:11
On Tue, 15 Sep 2009 06:16:06 -0700, markspace <nospam(a)nowhere.com> wrote, quoted or indirectly quoted someone who said : > volatile boolean done = false; > > while(!done) > processData(); > >"done" will be hoist out of the loop with out the volatile modifier, A local variable is by definition local to a single thread. They can't be volatile since no other thread can see them. Each thread running a method has its own stack and hence its own copy of each local variable. That is one of the beauties of local vs instance variables. -- Roedy Green Canadian Mind Products http://mindprod.com "Don�t worry about where you are. Watch the first derivative." translation: "Don�t worry about how things are. Watch where they are headed." ~ Fred Green (born: 1913-07-12 died: 1992-04-10 at age: 78) (my Dad, an electrical engineer) |