@FunctionalInterface
public interface ThreadContextSnapshot
The captured context represented by this snapshot can be applied to any number of threads, including concurrently.
Any state that is associated with context applied to a thread should
be kept, not within the snapshot, but within the distinct
ThreadContextRestorer
instance that this
ThreadContextSnapshot
creates each time it is applied
to a thread.
Modifier and Type | Method and Description |
---|---|
ThreadContextRestorer |
begin()
Applies the captured thread context snapshot to the current thread and
returns a distinct
ThreadContextRestorer instance. |
ThreadContextRestorer begin()
ThreadContextRestorer
instance. The
ThreadContextRestorer
instance tracks the context's life cycle,
including any state that is associated with it or that is necessary for
restoring the previous context.
For each invocation of this method, the Jakarta EE Product Provider
must invoke the corresponding
endContext
method exactly once, such that the previous context is restored
on the thread. If the Jakarta EE Product Provider sequentially begins
multiple ThreadContextRestorer
instances on a thread,
it must invoke the corresponding endContext
methods in reverse
order.