查看: 2738|回复: 0
打印 上一主题 下一主题

Unity3D多线程写法

[复制链接]

5552

主题

2

听众

8万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
11

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2012-6-27 14:53:36 |只看该作者 |倒序浏览
unity3d多线程写法

using UnityEngine;

using System.Collections;

using System.Threading;

public class MyThread

{

public int count;

string thrdName;

public MyThread(string nam)

{

     count = 0;

  thrdName = nam;

}

public void***n()

{

  Debug.Log("start***n a thread"+Time.time);

  do{

     Thread.Sleep(1000);

     Debug.Log("in child thread"+Time.time+"count="+count);

     count++;   

   }while(count <20);

   Debug.Log("end thread"+Time.time);

}
}

public class testThread : MonoBehaviour {

// Use this for initialization

void Start () {

  Debug.Log("start main"+Time.time);

    MyThread mt = new MyThread("CHILE ");

  Thread newThrd = new Thread(new ThreadStart(mt***n));

  newThrd.Start();

}
// Update is called once per frame

void Update () {

      Debug.Log(Time.time);

}

}
转自:http://www.netmego.com/xe/117999
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2025-2-8 13:49 , Processed in 0.070211 second(s), 29 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部