Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!newsfeed.CARNet.hr!gregory.BNet.hr!not-for-mail From: Josip Almasi Newsgroups: comp.lang.java.programmer Subject: Re: thread pool with waiting option Date: Sat, 12 Apr 2014 14:00:28 +0200 Organization: B.net Hrvatska d.o.o. Lines: 50 Message-ID: <53492ADC.8020509@vrspace.org> References: NNTP-Posting-Host: cpe-94-253-156-208.zg.cable.xnet.hr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: gregory.bnet.hr 1397304028 9350 94.253.156.208 (12 Apr 2014 12:00:28 GMT) X-Complaints-To: abuse@globalnet.hr NNTP-Posting-Date: Sat, 12 Apr 2014 12:00:28 +0000 (UTC) To: Philipp Kraus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:28041 Hi, think you could use Disruptors. However, do not think in 'thread' terms, think producer/consumer. Do not think 'get object from list', think 'receive event'. HTH;) Regards... On 04/10/2014 02:37 PM, Philipp Kraus wrote: > Hello, > > I would like to create a thread pool for a simulation environment. I use > a pool with objects an each object must be run once in a time step, eg > in pseudo code: > > while (true) > { > each thread in thread pool > { > get object from working list > object.run > push object into finished list > } > wait for all threads are finished > swap finished list with working list > > if user sends a wait signal > wait > if user sends a stop signal > { > clear working list > clear finish list > remove all threads > break > } > } > > Which datastructures can be used in Java for this structure? IMHO I > would like to use ExecutorService > but how can I create a pool which can be run again? In which way can I > create a good and fast solution? > > Hope for some ideas for this problem. Thanks a lot > > Phil > >