Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Nigel Wade Newsgroups: comp.lang.java.programmer Subject: Re: java thread question Date: Thu, 03 Apr 2014 16:17:34 +0100 Lines: 15 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net GmLF/01TUi6DmAnficaJFg81oq3DoLVFAfWyv7Mmuy/sJD4ilH Cancel-Lock: sha1:uDU6W2s0/Zq2sfO3pt/Q+68F6es= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:27943 On 03/04/14 15:51, mcheung63@gmail.com wrote: > Hi All > I have write a little program to keep running some threads, i got questions: > 1) All threads are running within one process (ps command show me this), but it will eat up all cpu cores, how to explain this? Because the OS can normally schedule any runnable process/thread to run on any available CPU core. If your process has sufficient threads which are runnable then every core will be used. One of the main purposes of threads is that they offer concurrent execution. > 2) If thread will eat multiple cpu core, why wee need fork/join in java? Fork starts another process, and this may run an entirely different executable. If your only goal is to consume CPU then you don't require fork.