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" <ch...@christopherschultz.net>
A: users@tomcat.apache.org
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: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


--
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: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to