public interface Threadable
In contrast to a Parallel
op, which marks an op that executes across
multiple threads, a Threadable
object knows how to provide multiple
independent versions of itself, each of which will be used from a separate
concurrent thread. Note that these versions may be deep copies, shallow
copies, or even the same instance every time, depending on the nature of the
object.
In a nutshell: Parallel
ops make use of Threadable
objects
for doing their work in a multithreaded way.
The requirement is merely that two threads using their respective object references as intended will not confuse one another's processing. As a rule of thumb, this means they might share read-only state, but not read-writable state (apart from perhaps lazily initialized state).
Parallel
Modifier and Type | Method and Description |
---|---|
Threadable |
getIndependentInstance()
Gets a reference to an instance of this object which can be used
simultaneously from a second thread while this instance is being used from
"its" thread.
|
Threadable getIndependentInstance()
It is expected that subclasses which override this method will narrow the return type appropriately. We do not enforce this at compile time via recursive generics due to their complexity: they introduce a host of typing difficulties.
Copyright © 2014–2022 ImageJ. All rights reserved.