A piece of code is considered atomic when its execution cannot be interrupted in favor of another process. Atomic code is necessary to preserve integrity when using shared resources.