Hi Nathan:
Thank you for the information and sorry for the careless
mistake.
Based on your book and information posted on the mail list.
It seems:
Q1: There are only two ways to create new threads when use
JNI on Linux (and other OS).
(a) use Thread.start in java code.
(b) let native code create a thread by using pthread_create and
attach the newly-created thread to JVM, so JVM, the multi-
threaded application, will create a sort of "internal thread"
for the attached native thread, right?
Q2: if use the first method, to make the new thread be created in
OS kernel, we need to use "java -native" to run the application.
If use "java -green", then the new thread won't be created in
OS kernel and it's fully controlled by JVM therefore it's in
user space and non-preemptive.
if use the second method, we have to use "java -native" to run
the application because native code uses native lib
(pthread_create) to create the thread. If "java -green" were
used to run it, would run into problems.
Do I understand them right?
Q3: With BlackDown 117_v3, the default behavior should be "green".
I can run a simple java application with "java app" or
"java -green app" without any problem (they are the same,right?).
But got an error msg like "java was not found in
/usr/local/jdk117_v3/bin/../bin/i686/native_threads/java" when
run it with "java -native app". Do I miss something?
Q4: What compile options I need to specify to pick up the right lib
if I want to run java app with green or native thread?
Thank you.
Lee
-----Original Message-----
From: Nathan Meyers [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 18, 2000 2:20 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: JNI and Dead Thread on Linux
On Tue, Jan 18, 2000 at 11:28:17AM -0600, [EMAIL PROTECTED] wrote:
> Hi:
>
> I got a few questions on JNI on Linux. It would be appreciated if someone
> could help.
>
> Suppose a shared library file has a function that is used to do hardware
> I/O, say hard drives R/W. A Java application uses JNI and calls this
native
> function in .so file twice to R/W two separate hard drives at the same
time.
> In this way, we should have two new threads (light weight processes) t1
and
> t2 created (am I right?).
Calling into native code doesn't create new threads - it just moves the
flow of control from the Java interpreter into some other native code.
After the JNI method returns, you're back to executing native code in the
Java interpreter.
Nathan
>
> Q1: Since Java application and two newly-created threads (t1 and t2) share
> the same memory space, if t1 messes up memory space and hangs, then Java
> application and t2 will hang too, right?
>
> Q2: If the answer to Q1 is "right", is it possible to protect Java
> application and t2 and prevent them from hanging after t1 is hung if we
use
> JNI?
>
> Q3: If the answer to Q2 is "no", then do you think out-proc solutions
(i.e.
> leave native functions in different memory spaces) like CORBA, TCP/IP and
> DCOM (not sure it's available now or not on Linux) are better than in-proc
> solution like JNI, so we can separate native functions in different memory
> spaces and prevent one from messing others? Is there any potential
problem?
>
>
> Thank you in advance.
>
>
>
> Lee
--
[EMAIL PROTECTED] Public Access User -- Not affiliated with Teleport
Public Access UNIX and Internet at (503) 220-1016 (2400-28800, N81)
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]