Multi-Threading: Preemptive?
Greetings all! I've got a little problem with the handling of threads on my machine. (I'm using RH5.1 w/ your jdk117) I'm finding that, given two threads of the same priority, the one that's currently getting CPU time will starve the other one until an explicit yield() or sleep() is reached. Is there any way to fix this? I've got a reasonably elegant workaround, but it's a workaround nonetheless, and I'm reluctant to make it a standard part of my code. (As I'll have to do in order to ensure that my code will work on all three of the platforms that it will be running on.) Any help or insights you guys can offer would be appreciated. Thanks! -chris *** The most important thing in the programming language is the name. A language will not succeed without a good name. I have recently invented a very good name and now I am looking for a suitable language. -- D. E. Knuth, 1967 *** -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Multi-Threading: Preemptive?
On Wed, 24 Feb 1999, David Craig wrote: > Java doesn't define how threads of the same priority share cpu time In > some VM implementations the sharing is fair. On others, such as the port > you're probably using, one thread preempts the other indefinitely. > > Congrats on an elegant workaround. :) > Actually, it's not my own invention, and I'm sure that others have done something similar. All I did was create a thread of "MAX_PRIORITY" that just goes right to sleep. It preempts everything else, then gives the little guys a chance to do their thing. (and I write a minimum of extra code to keep everything moving) Maybe "honorable hack" is a better term than "elegant". Thanks for the info- my java-idealism was getting just a little out of controll there for a second... ;) -chris *** The most important thing in the programming language is the name. A language will not succeed without a good name. I have recently invented a very good name and now I am looking for a suitable language. -- D. E. Knuth, 1967 *** -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Multi-Threading: Preemptive?
On Wed, 24 Feb 1999, Moses DeJong wrote: > I do not mean to rip on your code or anything, but if you require a Not at all. I'm pretty new (the last 3-4 years) to programming, and most of that has been in persuit of a CS degree, so I haven't had much of a chance to do any real coding. :( Right now I'm just testing a small piece of a larger puzzle. We need a component that will maintain an array of objects sorted according to their proximity to a point in space. That point will be changing moment-to-moment, so sorting on inserting won't be possible. The idea is that we plunk the object into the array at a likely spot, and let the array maintain the sort from there. Creating a thread to sort the array as resources permit seemed a good way to go. Any sugestions are welcome, and are greatly appreciated. -chris *** The most important thing in the programming language is the name. A language will not succeed without a good name. I have recently invented a very good name and now I am looking for a suitable language. -- D. E. Knuth, 1967 *** -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
