Skip to content

Latest commit

 

History

History
9 lines (5 loc) · 399 Bytes

PH_S007.md

File metadata and controls

9 lines (5 loc) · 399 Bytes

PH_S007 - Thread Start in Constructor

Problem

Side-effects inside constructors and especially starting new threads and tasks should be avoided in general as it is unexpected behavior. Moreover, if the newly started thread accesses data of the constructed instance it can lead to data races.

Solution

Create a factory method to instantiate the new object and start the respective thread.