| 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: 18670
|
|
|
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.
|
 |
 |
|
|
subject: Is java.security.MessageDigest methods digest() and reset() threadsafe
|
|
|