Added locks to transfer but program is infinite looping