Jsvc start/stop and threads

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Jsvc start/stop and threads

Andrea Lo Pumo
I am creating a thread in init(), and starting it in start().
In the user guide, there is written:
"void stop(): Inform the Thread to terminate the run(), close the
ServerSockets".
So in stop() I am interrupting my thread.
In the apidocs, there is written "the container may restart the Daemon by
calling start() after stop().". But, if my thread has finished, it cannot
be restarted again. (Thread.start() cannot be called after the thread has
completed execution).
So, what should I do?

Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Jsvc start/stop and threads

Greg Thomas
If you're terminating your thread, you'll simply need to start a new one.

Greg

On 5 June 2017 at 11:24, Andrea Lo Pumo <[hidden email]> wrote:

> I am creating a thread in init(), and starting it in start().
> In the user guide, there is written:
> "void stop(): Inform the Thread to terminate the run(), close the
> ServerSockets".
> So in stop() I am interrupting my thread.
> In the apidocs, there is written "the container may restart the Daemon by
> calling start() after stop().". But, if my thread has finished, it cannot
> be restarted again. (Thread.start() cannot be called after the thread has
> completed execution).
> So, what should I do?
>
> Thanks.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Jsvc start/stop and threads

Andrea Lo Pumo
So I need to create the thread inside start() and not in init().
Why in the documentation it is suggested to create threads in init()?
"void init(String[] arguments): Here open configuration files, create a
trace file, create ServerSockets, Threads"

Thanks for the prompt reply.

2017-06-05 12:27 GMT+02:00 Greg Thomas <[hidden email]>:

> If you're terminating your thread, you'll simply need to start a new one.
>
> Greg
>
> On 5 June 2017 at 11:24, Andrea Lo Pumo <[hidden email]> wrote:
>
> > I am creating a thread in init(), and starting it in start().
> > In the user guide, there is written:
> > "void stop(): Inform the Thread to terminate the run(), close the
> > ServerSockets".
> > So in stop() I am interrupting my thread.
> > In the apidocs, there is written "the container may restart the Daemon by
> > calling start() after stop().". But, if my thread has finished, it cannot
> > be restarted again. (Thread.start() cannot be called after the thread has
> > completed execution).
> > So, what should I do?
> >
> > Thanks.
> >
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Jsvc start/stop and threads

Bernd Eckenfels
These are just examples, depending on your use case. But I would agree that thread is a bad one, as it is quite normal to create and start them in start.

Gruss
Bernd
--
http://bernd.eckenfels.net
________________________________
From: Andrea Lo Pumo <[hidden email]>
Sent: Monday, June 5, 2017 12:30:41 PM
To: Commons Users List
Subject: Re: Jsvc start/stop and threads

So I need to create the thread inside start() and not in init().
Why in the documentation it is suggested to create threads in init()?
"void init(String[] arguments): Here open configuration files, create a
trace file, create ServerSockets, Threads"

Thanks for the prompt reply.

2017-06-05 12:27 GMT+02:00 Greg Thomas <[hidden email]>:

> If you're terminating your thread, you'll simply need to start a new one.
>
> Greg
>
> On 5 June 2017 at 11:24, Andrea Lo Pumo <[hidden email]> wrote:
>
> > I am creating a thread in init(), and starting it in start().
> > In the user guide, there is written:
> > "void stop(): Inform the Thread to terminate the run(), close the
> > ServerSockets".
> > So in stop() I am interrupting my thread.
> > In the apidocs, there is written "the container may restart the Daemon by
> > calling start() after stop().". But, if my thread has finished, it cannot
> > be restarted again. (Thread.start() cannot be called after the thread has
> > completed execution).
> > So, what should I do?
> >
> > Thanks.
> >
>
Loading...