当前位置:网站首页>Unity write multithreading considerations
Unity write multithreading considerations
2022-06-21 08:21:00 【kuilaurence】

First step :
using System.Threading; // Import header file
The second step :
private Thread threads; // Sub thread
void Start(){
threads = new Thread(SendMsg);
threads.Start();
}
private void SendMsg() // write in
{
Thread.Sleep(500); // Child thread delay 0.5s
Debug.log("hello world!");
}
public void OnDestroy() // Automatically destroy child threads on shutdown or exit
{
if (threads != null) {
threads.Abort(); }
}
tips: Cannot get in child thread Application.persistentDataPath;
It can be like this :
string persistent = "";
void Start(){
persistent = Application.persistentDataPath;
}
...
...
void SendMsg(){
// The method that the child thread runs
string path=persistent+"/test.txt";
...
...
}
边栏推荐
猜你喜欢
随机推荐
结构体类型的三种声明方式
For hand drawn graphics, covering multiple topics, CVPR 2022 sketchdl workshop begins to solicit contributions!
Redis master-slave vulnerability and remote connection vulnerability
Send using queue mailbox
Wechat official account docking: push article information to official account with one click
[redis]-[redis underlying data structure] - Dictionary
解密FTP
[DB written interview 220] how to back up control files in oracle? What are the ways to back up control files?
(thinking) C. differential sorting
【kotlin】第一天
Introduction to testing - Software Test Model
How to build a deep learning framework?
RISC-V 的MMU
What aspects should the enterprise multimedia exhibition hall design start from
Mongodb installation (Graphic tutorial)
(对于换行符)gets和fgets的区别,puts和fputs的区别
showCTF 入门文件包含系列
(for line breaks) differences between gets and fgets, and between puts and fputs
/home/ljx/miniconda3/compiler_compat/ld: cannot find crtbeginS.o: 没有那个文件或目录
Yunkang group passed the hearing: the revenue exceeded 1billion in 8 months and the profit within the period was 270Million







