add attach API and spin lock