Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are "atomic" and "synchronous" synonyms in programming?

Do "atomic" and "synchronous" mean the same thing or are there some minute differences?

Looking at the answers to this question, I think the answer to my question is yes, they're synonyms. Are the following true in general?

  • a synchronous operation will complete before the next operation starts
  • an atomic operation is the same as a synchronous operation
  • an asynchronous operation will complete at some point before or after the next operation starts
like image 242
Matt Avatar asked Mar 01 '26 23:03

Matt


1 Answers

Not quite the same. An atomic operation is one that can't be subdivided into smaller parts. So, in Java, assigning to an int is atomic: nothing can interrupt it, it either completes or doesn't.

A synchronous operation is one that simulates being atomic through some programming mechanism you invoke using the synchronized keyword. The implementation of that can vary.So in a synchronized block, the run time system enforces what's called a critical region in which only one thread of control can pass at the same time.

like image 147
Charlie Martin Avatar answered Mar 03 '26 12:03

Charlie Martin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!