|[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]|
From: Eric Albert <email@hidden>
Subject: Re: Thread crahes on my mac
Date: Thu, 30 Aug 2001 01:16:26 -0700
At 5:57 PM +1000 8/30/2001, dean perry wrote:I get the impression that the Classic VM performs some magic behind
the scenes to make Java seem "preemptively scheduled" on a
co-operatively scheduled OS... I'm guessing that by hitting certain
common methods, and at strategic opportunities (function calls?) the
VM tries to reschedule.
MRJ doesn't use the Thread Manager at all. It does its own
management of Java threads from scratch. That's actually less
difficult than it sounds because the VM has complete control over the
execution of Java instructions, so it can easily track Java threads
and switch between them whenever it feels that the current thread has
taken its entire time slice. A Java thread under MRJ is known only
to the VM, not to the OS, much like green threads in JVMs on other
platforms. No magic's necessary for this, just a lot of extra work
on the part of the VM authors.
The only that you should be able to get Java threads to block under
MRJ 2.2.x is if you keep the VM from being able to advance to the
next instruction. That's only possible if you have a host app that's
being uncooperative, a deadlock, or you've made a Java call that
triggers a synchronous and time-consuming native call (as is still
the case for a few networking functions, I believe). I can't think
of any way to prevent runnable threads from receiving time if another
thread is actually running and not blocked by one of those three
Of course none of this applies on Mac OS X, where Java threads are
native threads and the system supports preemptive scheduling.
Eric Albert email@hidden
java-dev mailing list
Visit the Apple Store online or at retail locations.
Copyright © 2011 Apple Inc. All rights reserved.