Native Threading With A Linux JDK?
mikej asks: "I've always had issues with the native threading of Sun's JDKs on Linux, but have been able to get around the problems by using green threads. I've come into a situation where I absolutely must use native threads, and the Blackdown-derived 1.3 [J/S]DK from Sun simply doesn't cut it (context switing time, which is a Linux issue, is part of the problem as well). Is there a reliable (and reasonably quick) native-threading JDK available for Linux? I much prefer a Free or Open Source version, but if I have to start using commercial software to get this functionality then I have no choice. In addition, are there different Linux threading libraries available?"
I don't know anything about it, but I am told IBM's JDK 1.3 is better than Sun's (I don't know in which sense). I don't know under which license it is published either. It is free for download, though. Stefan
Kaffe, an [the best] open source JDK, is your best bet.
It supports user-level threads (jthreads - recommended unless you want to spend weeks on each port to alternate platforms (of course you might require the speed of kernel threads - Java tends to be slow (although much of this is the overhead from the Virtual machine)) as well as standard Posix kernel threads.
Free Anne Tomlinson!!
Your problems are reliability and performance of the threading mechanism? Well, you could use Kaffe and tweak it to suit your needs, but let's consider this in more detail for a second.
The thread context switch time is indeed a Linux-wide problem. The latest 2.4-testX series does have some patches which will let the pthreads guys get around this problem, but unless you want to build it yourself, you are going to have to wait at least another 6 months for those changes to be well tested and rolled out. That being said Linux still manages to achieve high scores on VolanoMarks, so perhaps your problem lies elsewhere.
As far as stability, goes, the Sun JDK 1.3 is fairly stable by my count. On average it's been more stable than the IBM one (although the IBM one is sooooo fast)! If you are encountering a bug, I'd suggest:
This is probably the easiest way to get a more stable VM.
Finally, if thread context-switch time is really that important to you, might I suggest that you've either got a flaw in your design or that Java is perhaps not the best solution for your problem. There are real-time extensions to Java, but without those, it's pretty hard to get decent performance guaruntees about those kinds of things for Java.
sigs are a waste of space
I'm just curious: why do you need native threads?
Wouldn't you be better using C++? [Presuming you're using native threads for speed reasons.]
Or if there are other reasons for their use, wouldn't it be better to compile the Java source into native bytecode (using GCJ)? Although it wouldn't be as fast as C++ (by a factor of at least 3 times, according to tests), it would be at least somewhat faster.
Free Anne Tomlinson!!
Very, very odd. Anyone have any idea?
Have you tried the latest JDK from Sun? I have tried it, working with Enhydra, and it seems very good.
Later,
Mark