Fix. call `join` on gc for attached not joinable thread.
Code refactoring.