Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [OT] JNI + Threads



On Aug 30, 2005, at 04:58 , John W. Whitworth wrote:


On 30 Aug 2005, at 01:14, Josef Henryson wrote:


Greg,

Thanks for your reply. What I want is the following.

1. A component I need is implemented to be thread-safe and handle sessions. This means that the component itself does not manage threads but it saves session data locally with reference to the current thread.
2. I call this component which is a JNI-library (C++ & JNI files) from my Java code, e.g. a web application. I want to be sure that when I call the JNI library from the web application, the session data stored in the library is always associated with the same user thread. For example, the results from a second call should be based on saved data from the first call.


The people developing the component tells me this is the way sessions should be handled and that the Thread calling the library is linked to the session data. They are C++ developers however and I'm not convinced that this will work with Java in the same way as with C++.

I also need to know if a web server like Tomcat already handles sessions so that the same thread is always used for HTTP requests with the same session ID (from cookie or URL). Or is it necessary to handle threads yourself within the web application?

Many thanks, Josef




You should identify state by the session not the thread. A new request in the same session will be handled by a new thread in tomcat.

I do save the state by the session but the native library I use don't. My preference would be to pass on the session ID to the library that keeps the state based on the same session. But the developer of the library doesn't want to manage threads since it is very platform specific and they want the library to be as portable as possible between platforms.


So if each request starts a new thread in Tomcat then I'm in trouble. Thanks for the information.

Regards, Josef

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: [OT] JNI + Threads (From: Greg Guerin <email@hidden>)
 >Re: [OT] JNI + Threads (From: Josef Henryson <email@hidden>)
 >Re: [OT] JNI + Threads (From: "John W. Whitworth" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.