Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Knute Johnson Newsgroups: comp.lang.java.programmer Subject: Re: thread: catch the current thread in a share object Date: Sat, 26 Jul 2014 14:04:29 -0700 Organization: A noiseless patient Spider Lines: 30 Message-ID: References: <61f2c6cc-5832-466c-ac70-325df061fb17@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 26 Jul 2014 21:04:00 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="aaea3cd885ec60253a5a13f1f776dcc4"; logging-data="29065"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18qNg39bR5LuYpcseGkakHr" User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0 In-Reply-To: <61f2c6cc-5832-466c-ac70-325df061fb17@googlegroups.com> Cancel-Lock: sha1:tyOFiqlgmdn04Flg1UR1pRCHaT0= Xref: csiph.com comp.lang.java.programmer:29352 On 7/26/2014 09:20, Bert_emme wrote: > I try to implement a share object between thread. In the share object there is a queue. I want that if a condition is realizated the thread that at the moment lock the object go in wait and I want to put it in the queue of the shared object. But I don't idea on how referencing to this thread. > Example > > class ObjShare{ > Queue q; > > public synchronized mymethod(){ > > if(condition){ > q.put(thecurrentthread) > wait(); > } > } > > } > > Thanks in advance > Mauro > Mauro: Take a look at BlockingQueue in the docs. I think that is what you are looking for. One thread puts elements onto the queue and the other thread takes them off for processing. knute...