Update server api to use threads