KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I know volatile allows for visibility, AtomicInteger allows for atomicity. So if I use a volatile AtomicInteger , does it mean I don't have to use any more synchronization mechanisms? Eg. class A { private volatile AtomicInteger count; void someMethod(){ // do something if(count.get() < 10) { count.incrementAndGet(); } } Is this threadsafe?
Tags (comma-separated)
Save Edits
Cancel