Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: data shared between threads and synchronized on different objects Date: Tue, 02 Aug 2011 15:02:09 -0700 Organization: A noiseless patient Spider Lines: 21 Message-ID: References: <61899466-4def-4982-8aa9-b789aeead3ad@m22g2000yqh.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 2 Aug 2011 22:02:14 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="23836"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18jK2h2FAOjdqbmOhLv+Da8lRnLhmiEwMc=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 In-Reply-To: Cancel-Lock: sha1:XHM8AnT6OC9IfXYfaNJUtTjuPOU= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6770 On 8/2/2011 2:41 PM, Tom Anderson wrote: > On Tue, 2 Aug 2011, Marcin Rodzik wrote: > >> I have a thread (the essential piece of its code can be found here: >> http://pastebin.com/KM8Yiqgs) which sends some objects ("tasks") over >> the network (in method tryToSendTask). Another thread submits objects >> to be sent by means of the first thread's method submit - namely, the >> "task" is put into queue. >> >> [...] >> >> What do you think? > > I think you can make this a good bit simpler by using a BlockingQueue, That's funny. Marcin (Marteno?) posted this same question twice. I basically told him the exact same thing 6 hours ago, sans the nice code example.