File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Security and the fly likes Is java.security.MessageDigest methods digest() and reset() threadsafe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Security
Bookmark "Is java.security.MessageDigest methods digest() and reset() threadsafe" Watch "Is java.security.MessageDigest methods digest() and reset() threadsafe" New topic
Author

Is java.security.MessageDigest methods digest() and reset() threadsafe

Chase Bonham
Ranch Hand

Joined: Jul 15, 2006
Posts: 50
Are the java.security.MessageDigest methods digest() and reset() threadsafe?
Sam Semwal
Greenhorn

Joined: May 15, 2007
Posts: 19
MessageDigest probably isn't thread safe unless it's mentioned in the API.


TOGAF, SCJP 5.0, MBCS
Chase Bonham
Ranch Hand

Joined: Jul 15, 2006
Posts: 50
Thats where the confusion is for me. In the Javadoc for the lang API, is it safe to assume that if nothing is mentioned about synchronization then it is probably thread safe??..

Look at .. java.text.SimpleDateFormat, java.util.HashMap there is specific
mention of synchronization.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
In general the rule is that you should assume that a class is not designed to be used by multiple threads, unless the docs specifically say it is. It's true that some docs specifically tell you when a class isn't thread-safe, but that's not really necessary. There are also a few classes which are really thread-safe even though the docs don't say so, but you generally can't rely on that. The default is that classes are not thread-safe unless it's otherwise stated.


"I'm not back." - Bill Harding, Twister
Hongbing Kou
Greenhorn

Joined: Feb 14, 2011
Posts: 1
Confirmed that it is not thread safe. You will get weird errors after loading up your application in multi-thread environment.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is java.security.MessageDigest methods digest() and reset() threadsafe