Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx01.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!postnews.google.com!news2.google.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: Wed, 03 Aug 2011 10:34:11 -0500 Date: Wed, 03 Aug 2011 08:34:13 -0700 From: Patricia Shanahan 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: data shared between threads and synchronized on different objects References: <61899466-4def-4982-8aa9-b789aeead3ad@m22g2000yqh.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 28 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 70.230.200.54 X-Trace: sv3-uTTei9ouxhbjVMMI4v2mTPJ54i0JsJkreNcZK7/wuVbAfSDgm3LkykdA0pqP7j5yABrDmJCbJMtSAuK!oNV11iFbjx8yYraVgYKiq3HXDmWWVgtG74feT1+NWRlWbbdbfoNqSAPRnFGvQajmyDx43U4/N1E0!Bd/p9h4XxeqEJ2UPtQzY8Im4n3ecLbd6KmnMY5AJi41qdg== 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: 2393 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6775 On 8/3/2011 6:29 AM, Tom Anderson wrote: > On Tue, 2 Aug 2011, markspace wrote: > >> 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. > > How embarrassing. I must pay more attention to what's going on around here. Maybe duplicate, independent recommendations for the same solution will encourage the OP to look at it. Patricia