dart Isolate使用案例
2023-11-13 Android 552
import 'dart:isolate'; void printMessage(var message) { var sendPort = message[0] as SendPort; var msg = message[0] as String; print('Message: $msg'); sendPort.send('Hello from new Isolate!'); } void main() async { var receivePort = ReceivePort(); Isolate iso = await Isolate.spawn(printMessage, [receivePort, 'Hello!']); receivePort.listen((message) { print('Received: $message'); }); receivePort.close(); iso.kill(); }
很赞哦! (0)
相关文章
文章评论
-
-
-
0条评论