This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

do we need separate thread for FirstThread


When JvRunMain starts it creates a new thread, and executes the Java
'main' method in that thread.  It would be nice if we could instead
"attach" the the first thread to the existing 'start' thread, and
run there.  Some reasons:

* Behaves more as "expected" if Java main method is called like C main
function.

* Avoid creating threads in single-threaded programs.

* Main thread can use (presumably larger) initial stack.

* Easier for a debugger to work with Java prgrams, especially
single-threaded ones.  I've tried using gdb on Kawa, and there
are major problems.  Some of these I suspect are related to
threading, and it would be easier to make gdb useful if we could
concentrate on the non-thread related issues first.  For example,
it seems like the thread library (pthreads on Linux) causes lots
of signals that are reported by Gdb.  This is nothing but confusion,
and people running a single-threaded Java program shouldn't have
to worry about threads and signals.  I'm sure gdb could be set up
to hide these artifacts, and that is probably needed once we want
to debug multi-threaded programs.  But for now, it would be nice
to avoid it.

* The initial location that gdb looks at should be the main
function for C/C++ and the main method for Java.  My feeling
is that this will be easier/cleaner to get right if they are
the same thread.

* The JNI invocation interface requires the ability to attach a
JVM to an existing native thread.

The last I think is the killer argument, but the other ones
are also worth noting. So what are the arguments in favor of
starting a separate native thread?  Uniform representation for
all Java threads?  But we have to treat FirstThread special
anyway, at least when we start it up.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]