---
title: 基本原理
description: "提供以下几种同步机制："
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/programug/acldevg/aclpythondevg_0023.html
sourcePath: /source/zh/canncommercial/900/programug/acldevg/aclpythondevg_0023.html
indexId: 3d071b6279250e35c79fe09c03f8da0d632f01b784ba571a0df350db013c602d71
---
# 基本原理

#### 同步机制

提供以下几种同步机制：

- Event的同步等待：调用  acl.rt.synchronize_event(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclpythondevg_01_0098.html)
接口，阻塞应用程序运行，等待Event完成。
- Stream内任务的同步等待：调用  acl.rt.synchronize_stream(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclpythondevg_01_0087.html)
接口，阻塞应用程序运行，直到指定Stream中的所有任务都完成。
- Stream间任务的同步等待：调用  acl.rt.stream_wait_event(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclpythondevg_01_0101.html)
接口，阻塞指定Stream的运行，直到指定的Event完成。支持多个Stream等待同一个Event的场景。接口调用流程请参见  关于Stream间任务的同步等待（通过Event实现）
。
- Device的同步等待：调用  acl.rt.synchronize_device(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclpythondevg_01_0070.html)
接口，阻塞应用程序运行，直到正在运算中的Device完成运算。多Device场景下，调用该接口等待的是当前Context对应的Device。
