Martin Sorgatz writes:
> Martin Schmitz wrote:
>
> > please look at this small example!!
>
> what example?
>
> > it creates a thread, but the output is done after the main thread did
> > his work!!!
> > on windows it works fine!
> >
> > i've another software where i create a thread which is running endless,
> > but it blocks the GUI.
> >
> > so were is the problem with threads in linux???
>
> I think the problem with threads in Linux is the thread scheduler.
> Your linux-vm uses "green threads" which means that the thread scheduler
> works priority controlled.
> The windoze vm uses a time scheduler.
> With green threads the thread with highest priority will run until
> completion.
>
> I don't know if there exists a native threads vm for linux.
> To work around this problem you can let your threads behave nicely
> by calling Thread.yield() from time to time to allow other threads to
> execute.
There's no native threads VM from the JDK porting team; the "Open" Group has a
version of the JDK for Linux that uses native threads, unfortunately, their
diffs are not "open".
In general, thread scheduling policy in Java is implementation dependent, and
any Java program that depends on a particular thread scheduling policy or
frequency is inherently nonportable. It's not that difficult to create
portable programs that handle all kinds of different threading implementations;
HotJava is one such example that works on everything from Solaris green
threads, to NT (which is, in many ways, the most demanding because it uses
preemptive scheduling of threads, which means that a thread switch can occur at
*any* time, and not just during I/O).
Steve