This lesson is going to be really short, I'm sure at some point in the future you're going to come
across atomic types, and this is a perfect time to explain what it is.
Atomic types let you safely update variables across multiple threads.
They're also cleaner and faster than locks.
So if you're a variable is being updated by many threads, then simply declaring it as an atomic can
make your code thread safe.
Some now declare this as an atomic integer.
Which is equal to a new atomic integer.
With the value of zero.
And now this is not a primitive type anymore, it's a class type.
So instead of saying counter plus plus, we're going to say counter and we're going to call the ad and
get method from the atomic energy class.
And so what the ad part is going to do is during its run, it's going to add one.
And what Dick Gephardt does is it returns the updated value.
And now we don't have to use locks anymore.
If we rerun the code.
Even across multiple threads, our calendar gets updated correctly.
And so why were we able to remove the lock?
Well, atomic variables are special in the sense that when this atomic variable is being accessed and
updated by one thread, and let's say another thread tries to join in, it's going to say, Whoa, whoa,
whoa, wait your turn.
And so they're pretty special in that sense.
So to keep it short, whenever possible, they were using an atomic type over a lock.
It's cleaner and typically faster, so we can remove this lock parameter right here.
We don't need it anymore.
I'm here as well, and you can remove the re-entering clock declaration.