java - ImageIO thread-safety -


I see that yarn-security is not a goal, even if the web Many examples have been seen using the imageIO.read () and ImageIO.write () to upload / clean images in the environment.

So, my question is, according to the tip, is ImageIO thread-safe?

TLDR; Yes, static methods ImageIO.read (...) and type (...) threads are safe I


one of the specification The part that says that there is a need to read in context. What is actually said is that the person does not have to worry about thread protection for the ImageReader , ImageWriter or ImageInputStream / ImageOutputStream implementation (And as a result, the client code should never be guessed that the threads are secure). Unless you live according to this rule, you are safe. However, note that the same part of the device also states that:

[...] Many instances of the same plug-in class should be possible to simultaneously operate .

This part of the specification does not specifically discuss the static methods of ImageIO , but the above quotation means that the tess methods are safe in thread, as Creates a new example of imageIO.read (...) and writing (...) ImageInputStream / ImageOutputStream And for each invitation, it is not really "despite the device" for the ImageReader / ImageWriter .

ImageIO contains many other static methods in the class which are safe in use, and the class itself (mostly *) is stateless if it does not work in this way, then it Actually there will not be too much use ...

*) IIORegistry example of ImageIO class is built on construction time, and whenever < Code> scanForPlugins () method is implemented. If you implement two threads at the same time, you may get problems (ie plugins can not be registered properly), but through client code control / when this happens, you can easily avoid it. There are also threads group CacheInfo , but its usage is being synchronized properly.


Disclaimer, I did not write fiction, but this is my interpretation (and I have used ImageIO in countless, multithrred applications, as well as a dozen or so ImageReader and ImageWriter are written manually in plugins).

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -