Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.CARNet.hr!gregory.BNet.hr!not-for-mail From: Josip Almasi Newsgroups: comp.lang.java.programmer Subject: Re: thread pool with CachedThreadPool Date: Wed, 16 Apr 2014 12:42:25 +0200 Organization: B.net Hrvatska d.o.o. Lines: 23 Message-ID: References: <12vmb157ulwwb.1cmusyz7wuuyi$.dlg@40tude.net> NNTP-Posting-Host: 94.253.178.60 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: gregory.bnet.hr 1397644945 15825 94.253.178.60 (16 Apr 2014 10:42:25 GMT) X-Complaints-To: abuse@globalnet.hr NNTP-Posting-Date: Wed, 16 Apr 2014 10:42:25 +0000 (UTC) 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:28100 On 04/16/2014 08:43 AM, Robert Klemme wrote: > On 16.04.2014 00:05, Daniel Pitts wrote: > >> "Threads" with nothing to do take up very little CPU. They may take up >> memory or other resources, but they can be made to do nothing until >> called for. > > What do they take CPU for other than that negligible amount of time the > kernel takes for administering them? I'd say for all practical purposes > you can assume a blocked thread to take up zero %CPU. Or am I missing > something? Blocked thread itself spends no cpu time. Running thread may spend some more cpu time though, for lock checks. Real issue is flushing pipeline to ensure cache coherency among all cpu cores. So, more 'synchronized' statements your single running thread encounters, more cpu stalls. It's not really 'taking' cpu time, it's wasting it. I have to admit, intel pipeline is complete mistery to me:) But that's why have atomics and other non-blocking thread-safe magic. Regards...