1.多个isolate间通信

1.1把isolate1注册到IsolateNameServer

/// A port used to communicate from a background isolate to the UI isolate.
    final ReceivePort port = ReceivePort();

    /// Register the UI isolate's SendPort to allow for communication from the background isolate.
    IsolateNameServer.registerPortWithName(
      port.sendPort,
      isolateName,
    );
    port.listen(_doJob);

1.2在另外一个isolate2中,获取到刚刚的SendPort,然后发送数据

final SendPort _uiSendPort =
        IsolateNameServer.lookupPortByName(isolateName);
    _uiSendPort?.send('_alarmCallback');

这时会执行isolate1中的_doJob方法。

以上,是一次完整的isolate间的单向通信过程。