Changes made in generator.h to make the vaiables atomic.
The variables are being read/written by different threads
and to avoid any consistency problem, making it atomic