clustering with threading and synchronizing.