thread race condition - use synchronized on critical write+read section