Fix incorrectly defined thread functions