You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by kz <kh...@gmail.com> on 2007/03/21 08:45:46 UTC

Same thread for calls to Native methods

Hi,

Is it possible to configure Tomcat so that it spawns just one thread for
calling all the methods of native code (the native methods are called from
servlets)?

Actually I am having a problem that I call a native method (C++ is the
native language) and from the native code I initialiize some pointers (COM
interface pointers). The problem is that when Tomcat uses a different thread
to call a different method of the same DLL then the pointers which were
initialized become invalid (COM pointers require marshalling to make them
valid in a different thread but I wanted to know if any oter solution is
possible). This problem is not coming if we use Jigsaw as our web server. Is
there any option in Tomcat which can make Tomcat use one thread for calling
native methods? Or is there any other solution to this problem?


Khurram.

Re: Same thread for calls to Native methods

Posted by Leon Rosenberg <ro...@googlemail.com>.
You can easily avoid this problem by introducing an abstraction layer
which is called by the servlet and which maps the calls to the one
internal thread, which is associated with native libs. You can use a
queue to synchronize the calls.

regards
Leon

On 3/21/07, kz <kh...@gmail.com> wrote:
> Hi,
>
> Is it possible to configure Tomcat so that it spawns just one thread for
> calling all the methods of native code (the native methods are called from
> servlets)?
>
> Actually I am having a problem that I call a native method (C++ is the
> native language) and from the native code I initialiize some pointers (COM
> interface pointers). The problem is that when Tomcat uses a different thread
> to call a different method of the same DLL then the pointers which were
> initialized become invalid (COM pointers require marshalling to make them
> valid in a different thread but I wanted to know if any oter solution is
> possible). This problem is not coming if we use Jigsaw as our web server. Is
> there any option in Tomcat which can make Tomcat use one thread for calling
> native methods? Or is there any other solution to this problem?
>
>
> Khurram.
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Same thread for calls to Native methods

Posted by Pe...@wcenter.de.
Hi Khurram,

As a "Pure Java" workaround, I would use a Singleton to collect work 
orders from various servlet-threads. That singleton would create one 
worker thread and feed it sequentially with work for the native code. 

Regards,

Peter Henningsen
Senior Consultant

<<
Is it possible to configure Tomcat so that it spawns just one thread for
calling all the methods of native code (the native methods are called from
servlets)?
<<