Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: markspace Newsgroups: comp.lang.java.programmer Subject: Re: thread: catch the current thread in a share object Date: Sat, 26 Jul 2014 10:08:07 -0700 Organization: A noiseless patient Spider Lines: 26 Message-ID: References: <61f2c6cc-5832-466c-ac70-325df061fb17@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 26 Jul 2014 17:08:13 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="9358cda03e1e0dfd3c4b757daa608707"; logging-data="1182"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18wToaSbwHNyEXmsF2+M4wnQx2/ClsCjUc=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <61f2c6cc-5832-466c-ac70-325df061fb17@googlegroups.com> Cancel-Lock: sha1:zbj//myUFaYvmbn6QeC5D6FQyTs= Xref: csiph.com comp.lang.java.programmer:29343 On 7/26/2014 9:20 AM, 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. I don't know what you are trying to accomplish here. And it doesn't not sound like good design. But it also sounds like you don't know about Thread.currentThread(). > class ObjShare{ > private Queue q; > > public synchronized mymethod(){ > > if(condition){ > q.put( Thread.currentThread() ) > wait(); > } > } > > }