lb: use atomic operations to avoid data races