fixed potential bug

the thread function can start before all member variables are correctly initialized, so we create the thread after the variable initialization
added some spaces