I think you can as long as you can deal with the complexity of converting a synchronized block to a non synchronized atomic program/block/or anything it means as per your changed algorithm. If you have many variables that need to be atomically updated, you may sometimes need to write your own implementation classes and there are chances that you may need to change your algorithm a great deal. Also you may have to test it thoroughly and testing multi-threaded applications is inherently tough.
I'd consider the readwrite locks' suggestion ( if applicable ) posted above.
Joined: Sep 06, 2012
Can we use the Atomocity concept as it is more effective than Synchronized block ?
is a very general ( not sure if it is a correct statement) statement. I'm not sure if atomic classes are more effective though ( remember the extra looping - even though it may be just one extra loop ). I think synchronization should be brief and focused and atomic classes should be used if they don't make your implementation very complex and you need to minimize synchronization. I think there is a trade off here and you can't say one is more effective than the other cause they both achieve different things. May be it depends on what you mean by effective.
Of course, there are more qualified people to talk about it. :-)