Fixed race conditions in int_generator using lock