What are atomic actions and why they are neccessary? Also, How are atomic actions implemented in Java?
My understanding is that in programming an atomic action is one that effectively happens all at one. An atomic action cannot stop in the middle it either happens completely or not at all.
For example, ordering an airline ticket online where two actions are required: payment and a seat reservation. The potential passenger must either.
- both pay and reserve a seat, OR
- neither pay nor reserve a seat
Maybe you should think about transactions. Make some process but do not save changes until everything is in order. Like when you are withdrawing money from a machine, you follow a series of steps, before seeing changes on your account, i.e. Put your card, your password, say how much money you want, receive the money. If something fails in one of the steps, you dont see changes in your savings account, e.g. your password was incorrect, or you are trying to withdraw more money than what you have…
You can read the java tutorial.
http://docs.oracle.com/javase/tutorial/essential/concurrency/atomic.html