This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Security and the fly likes Is 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 methods digest() and reset() threadsafe" Watch "Is methods digest() and reset() threadsafe" New topic

Is methods digest() and reset() threadsafe

Chase Bonham
Ranch Hand

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

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

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

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

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Is methods digest() and reset() threadsafe
It's not a secret anymore!