Thread initialization.