Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.datemas.de!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: Wormholes Date: Wed, 05 Sep 2012 17:34:59 -0700 Organization: A noiseless patient Spider Lines: 32 Message-ID: References: <0ska4895k2mp2j5fb5p4qnue7lsbdpoeoo@4ax.com> <85zk56mgi1.fsf@teletu.it.nospam.invalid> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 6 Sep 2012 00:35:02 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="61282af8d6595e8d991edb5ac03d6e00"; logging-data="28112"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+BSfKUXvZnb6u0cKqjZ7iVVrXIdyTgNTc=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120824 Thunderbird/15.0 In-Reply-To: Cancel-Lock: sha1:zea/zMcwqr78KhEpZwcPons8tn0= Xref: csiph.com comp.lang.java.programmer:18562 On 9/4/2012 1:20 PM, Roedy Green wrote: > On Tue, 04 Sep 2012 08:47:18 +0200, Zermelo > wrote, quoted or indirectly quoted > someone who said : > >> Add a static variable to x accessible to y. > > it would have to have default scope. I hoping there was a technique I don't think default scope would work. Consider the case where multiple threads call the method in question. If the second thread over-writes the first thread's value before it gets used, you'll have serious errors. Something like a ThreadLocal is required here. Something that simulates the call stack frame. > that would behave like that, but which would not expose the variable > to the entire package, when really only one method should use that > variable. > > The techniques that I can think of are default scope variable or pass > value down call chain to where it is used. Are there any others? Is there any way you can show us the code? I'm curious as to why it's so hard to refactor.