Native Threading With A Linux JDK? 14
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?"
IBM JDK (Score:1)
Kaffe (Score:2)
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.
The Sun JDK does a decent job... (Score:4)
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.
Why native threads? (Score:2)
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 [redhat.com])? 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.
Re:Why native threads? (Score:1)
He probably doesn't like the lack of flexibility of ordering... perhaps he wants to make threads with higher priority than their parent.
I wish he'd be more forthcoming with the details; it could be an educational conversation.
I think he might want to try out HotSpot, if it's just performance. But it takes just a few seconds to spawn 10,000 threads on a midrange 'puter, optimizing VM or not...
Re:Why native threads? (Score:2)
An alternative is identifying your slow code and rewriting those areas to native code. (which makes the Java application platform dependent but faster.)
Strange Java problems (Score:1)
Very, very odd. Anyone have any idea?
JDK 1.3 From Sun (Score:1)
Later,
Mark
Re:IBM JDK (Score:3)
Re:Why native threads? (Score:2)
Compiling the Java source into native bytecode doesn't help. First, you lose all the benefits of server-side Java (the program ends up just like C++ in this instance--no object pooling).
Now, I have no idea what the original author is trying to do. But this response simply doesn't make sense for server-side programming. Generallly, server-side programming is one area that is well suited towards creating large amounts of threads.
One thing the author could try to do is to either run WinNT or Solaris. Both of these OSes have much more effective threading models than the 2.2.x kernels (shudder--WinNT is better at something than Linux!). I'd recommend Solaris, personally. It scales much better to large hardware. And you still get the Unix environment.
YMMV.
Re:JDK 1.3 From Sun (Score:1)
Yes, he has.
Re:IBM JDK (Score:1)
Re:Why native threads? (Score:1)
Re:Why native threads? (Score:2)