× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I would like to give a big thanks to David Morris for spending some time 
finding a solution for this one!  The problem was that the AS400 system 
object is *not* thread safe.  I was passing an AS400 system object into 
each of my worker threads and after swapping the first time I would get a 
"Password is not set" error message.  After making some minor 
modifications to the code to create a new AS400 object for each worker 
thread the problem has gone away and I can be multithreaded again!

Thanks Dave,
Phil




Phillip Denis/Richer Systems Group Inc. 
20/07/2006 03:33 PM

To
java400-l@xxxxxxxxxxxx
cc

Subject
Re: ProfileTokenCredential and multithreaded application





I am sending this post a second time ... the first time was back in May 
and there has been no response in 2 months.  Is that because no-one knows 
the answer??  Surely there is a list moderator that can shed some light on 
the situation ...  This is now becoming a showstopper for my application 
because I have had to make my application SINGLE THREADED to work properly 
and it is about to get a lot more load.  Now tasks have to be handled 
serially instead of concurrently.  There must be a better way ...

Hopefully someone will respond this time ...

Thanks,
Phil

---------------------------------------------------
Original Message
---------------------------------------------------
I have a server daemon program written in Java that does the following:
        - Monitor a data queue waiting for a request to come in
        - When a request is read, spawn a worker thread to do the work and 

go back to monitoring the queue
        - The worker thread uses ProfileTokenCredential to swap to a 
different user profile to do some work on behalf of that user and then 
swaps back and finishes.

According to the javadoc for ProfileTokenCredential:
"When referenced from a running process on the associated iSeries system, 
a profile token can be used to modify or swap the OS/400 thread identity 
and perform a specific task or tasks on behalf of the authenticated user."

The problem is when one worker thread swaps user profiles it seems to swap 

the thread identity of the ENTIRE JVM and not just that one worker thread. 

 This causes the other worker threads to be working on behalf of the wrong 

user, and all sorts of problems ensue.  The main thread that is monitoring 

the data queue cannot read entries from it anymore without throwing 
"Password is not set" errors, the worker threads

My question is ... are native threads supported by the iseries JVM?  My 
thoughts are that if there is a native thread backing each of the worker 
threads then maybe .. just maybe .. ProfileTokenCredential will only 
change that thread's os400 identity and not the others. 

Anyone have any ideas on this one?

Note - executing the following command from QSH does not work.  It just 
prints a help message and fails:
        java -native HelloWorld

Thanks,
Phil Denis

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.