thread constructor example
refactoring on a minor scale