Pergunta de entrevista da empresa Ant Group

How to prevent deadlock? Which type of lock to use?