Is it safe to use InheritedThreadLocal for context management in activities

We are using temporal SDK with spring and initiating worker on app startup and
we are using InheritedThreadLocal for maintaining context in activities.

activity start → context update → use context inside the @Component/@Service classes that are passed to activity implementation constructor.

sometimes context is getting overwritten by other activities. how can i mitigate this?

Can you give more info, or a small sample? Are these activities implemented in same activity impl?

My guess is this could be because you register a single activity impl with the worker which would be used for all activity executions of the activities it contains. Could test by having each individual activity in its own activity interface and impl.

What’s the use case for InheritedThreadLocal?