Thread-proofing and selection sort implementation