Using threads for sunshine algorithm