#include <thread>
#include <iostream>
#include <cassert>
#include <chrono>
#include <mutex>
#include <atomic>

std::atomic<int> counter = 65535;

void worker(int delta) {
	for (auto i = 0U; i < 100; ++i) {
		std::this_thread::sleep_for(std::chrono::milliseconds(20));
		counter.fetch_add(delta, std::memory_order_release);
	}
}

int main() {
	std::cout << "int is atomic? " << std::atomic<int>{}.is_lock_free() << '\n';

	auto t1 = std::thread(worker, 1);
	auto t2 = std::thread(worker, -1);

	t2.join();
	t1.join();
	assert(counter == 65535);
}
