Spec-Zone .ru
спецификации, руководства, описания, API
|
CONTENTS | PREV | NEXT | JavaTM Image I/O API Guide |
Thread Safety
A particular instance of anImageReader
orImageWriter
is not required to support re-entrant (simultaneous) calls to its methods (with the exception of theabort
method that requests current read or writes to halt). However, it must be possible for multiple instances of the same plug-in class to operate simultaneously. For the sake of brevity, we will only discuss reader plug-ins below.Supporting full re-entrancy would require that the reader bundle all of its state information (e.g., the current input source) into a separate state object, which would allow methods in progress to continue to work with the settings that were in effect at the time they began, while allowing a separate thread to modify the state to be used by the next operation.
Rather than forcing each
ImageReader
to keep track of its state in this way, it is simpler to require the application to instantiate multiple instances of the sameImageReader
class if it wishes to perform multithreaded processing. This means that the state of anImageReader
must be maintained using non-static instance variables only, which should not be a burden for plug-in developers.