Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: Recommendations for Lightweight Threading? Date: Fri, 15 Jun 2012 15:55:39 -0700 Organization: A noiseless patient Spider Lines: 32 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 15 Jun 2012 22:55:42 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="7zTeebvKpIS8LVJ5OFDmwg"; logging-data="16185"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+HSx6szLGETwJKdWCJnCsaG/Ih5ANvOeg=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 In-Reply-To: Cancel-Lock: sha1:pnpdhWq6FqygKV9B/GbxltgMk4g= Xref: csiph.com comp.lang.java.programmer:15312 On 6/15/2012 3:33 PM, Aaron W. Hsu wrote: > I am considering moving one of my projects from C to Java, but I am > hoping to find a high-performance threading implementation, or something > along the lines of libqthread, which offers Fill-Empty bit blocking and > good cooperative lightweight threading as a library. > > Is there a current "best" solution when doing many threaded programs in > Java? By many threads I mean many more than the cores or machines on the > network. Something that scales up efficiently to distributed computing > would be nice as well. > As far as I know, the built-in class java.lang.Thread is the only game in town. The JVM is responsible for implementation, it will use pthreads or native processes or whatever is considered "best" on a given platform. (Did you really mean "libqthread" or "libpthread"?) Java doesn't do "special libraries on each platform" like C does. Java puts all its effort into making the one implementation there is be as fast and as efficient as possible. That's a bit of a change of mind-set for a lot of folks, but it works very well in practice. I'd do some bench-marking first before you decide to try to import special libraries. There are of course libraries in the Java API. Be sure to check out the java.util.concurrent package. Actually using Thread directly is considered noobish these days. Here's a primer: