Any reason NOT to slap the 'synchronized' keyword everywhere?
Posted
by unknown
on Stack Overflow
See other posts from Stack Overflow
or by unknown
Published on 2009-06-11T03:01:07Z
Indexed on
2010/06/12
19:32 UTC
Read the original article
Hit count: 134
In my java project, almost every non-static method I've written is synchronized
. I've decided to fix up some code today, by removing most of the synchronized
keywords. Right there I created several threading issues that took quite a while to fix, with no increase in performance. In the end I reverted everything.
I don't see anyone else writing code with "synchronized
" everywhere. So is there any reason I shouldn't have "synchronized
" everywhere?
What if I don't care too much about performance (ie. the method isn't called more than once every few seconds)?
© Stack Overflow or respective owner