Pausing all thread but one.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Pausing all thread but one.

Tullio Bettinazzi
I need to perform some maintenance operations pausing all user thread for a small but meaningfull time (say 30 secs).
Is it possible to pause all user threads ?
How ?
Any suggestion ?
Tks

Dott. Tullio Bettinazzi
Responsabile R & D
Axioma - Tel. +39 039 22511
www.axioma.it

Trattamento dei dati personali conforme ai sensi del Regolamento Europeo 2016/679



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Pausing all thread but one.

Christopher Schultz-2
Tullio,

On 10/28/20 06:27, Tullio Bettinazzi wrote:
> I need to perform some maintenance operations pausing all user thread
> for a small but meaningfull time (say 30 secs).

Ugh. Why? What do you need to do that can't be handled with "proper"
synchronization?

> Is it possible to pause all user threads ?

Maybe. It's very dangerous, though.

https://docs.oracle.com/javase/8/docs/technotes/guides/concurrency/threadPrimitiveDeprecation.html

> How ?

I'll leave that as an exercise for the reader at this point.

> Any suggestion ?

Yes: think if a better way to do what you are trying to do.

This sounds like an X-Y problem[1]. You are trying to do X and you have
decided that you need to do Y in order to accomplish X. So you are
asking about Y.

Why not just ask about X instead?

-chris

[1] http://xyproblem.info/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Pausing all thread but one.

Tullio Bettinazzi
OK tks for the X-Y explanation.
I need to reload a few caches and when theese caches are reloaded nobody can access them.
This is my problem.
Tks

Dott. Tullio Bettinazzi
Responsabile R & D
Axioma - Tel. +39 039 22511
www.axioma.it

Trattamento dei dati personali conforme ai sensi del Regolamento Europeo 2016/679

----- Messaggio Originale -----
Da: "Christopher Schultz" <[hidden email]>
A: [hidden email]
Inviato: 28/10/2020 20:13
Oggetto: Re: Pausing all thread but one.

Tullio,

On 10/28/20 06:27, Tullio Bettinazzi wrote:
> I need to perform some maintenance operations pausing all user thread
> for a small but meaningfull time (say 30 secs).

Ugh. Why? What do you need to do that can't be handled with "proper"
synchronization?

> Is it possible to pause all user threads ?

Maybe. It's very dangerous, though.

https://urlsand.esvalabs.com/?u=https%3A%2F%2Fdocs.oracle.com%2Fjavase%2F8%2Fdocs%2Ftechnotes%2Fguides%2Fconcurrency%2FthreadPrimitiveDeprecation.html&e=af66902b&h=887af54c&f=y&p=n

> How ?

I'll leave that as an exercise for the reader at this point.

> Any suggestion ?

Yes: think if a better way to do what you are trying to do.

This sounds like an X-Y problem[1]. You are trying to do X and you have
decided that you need to do Y in order to accomplish X. So you are
asking about Y.

Why not just ask about X instead?

-chris

[1] https://urlsand.esvalabs.com/?u=http%3A%2F%2Fxyproblem.info%2F&e=af66902b&h=9b6e4fa6&f=y&p=n

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


--
This message has been checked by Libraesva ESG and is found to be clean.
Follow this link to mark it as spam:
https://gw1.idrnet.it/action/B465842741.A19C7/learn-spam
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Pausing all thread but one.

Christopher Schultz-2
Tullio,

On 10/29/20 04:42, Tullio Bettinazzi wrote:
> OK tks for the X-Y explanation.
> I need to reload a few caches and when theese caches are reloaded nobody
> can access them.
> This is my problem.

Your caches must be thread-safe, otherwise you would have serious
problems. (You might want to go check on that, now.)

The solution is simple: in your cache-reload thread, just loop through
your caches, locking each one, emptying it, re-filling it, and then
unlocking it. All will be well, and you don't have to pause any threads.

What will happen is any in-flight requests will simply pause waiting for
you, which is exactly how they would have behaved if you had "paused"
the threads and then let them go.

So the user's experience is the same, and your code is simpler and safer.

-chris

> ----- Messaggio Originale -----
> Da: "Christopher Schultz" <[hidden email]>
> A: [hidden email]
> Inviato: 28/10/2020 20:13
> Oggetto: Re: Pausing all thread but one.
>
> Tullio,
>
> On 10/28/20 06:27, Tullio Bettinazzi wrote:
>  > I need to perform some maintenance operations pausing all user thread
>  > for a small but meaningfull time (say 30 secs).
>
> Ugh. Why? What do you need to do that can't be handled with "proper"
> synchronization?
>
>  > Is it possible to pause all user threads ?
>
> Maybe. It's very dangerous, though.
>
> https://urlsand.esvalabs.com/?u=https%3A%2F%2Fdocs.oracle.com%2Fjavase%2F8%2Fdocs%2Ftechnotes%2Fguides%2Fconcurrency%2FthreadPrimitiveDeprecation.html&e=af66902b&h=887af54c&f=y&p=n
>
>  > How ?
>
> I'll leave that as an exercise for the reader at this point.
>
>  > Any suggestion ?
>
> Yes: think if a better way to do what you are trying to do.
>
> This sounds like an X-Y problem[1]. You are trying to do X and you have
> decided that you need to do Y in order to accomplish X. So you are
> asking about Y.
>
> Why not just ask about X instead?
>
> -chris
>
> [1]
> https://urlsand.esvalabs.com/?u=http%3A%2F%2Fxyproblem.info%2F&e=af66902b&h=9b6e4fa6&f=y&p=n
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
> --
> This message has been checked by Libraesva ESG and is found to be clean.
> Follow this link to mark it as spam:
> https://gw1.idrnet.it/action/B465842741.A19C7/learn-spam
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]