您的位置:首页 > Web前端

[coding] Threading differences in C# and Java

2004-12-07 17:16 525 查看
C#

using System.Threading;
public class myThread
{
static public void RunThread()
{ /* do work */ }
}
public class TestThread
{
public static main( )
{
Thread NotifyThread = new Thread(new ThreadStart(myThread.RunThread));
}
}

Java
public class myThread implements Runable
{
public void run() //must override run()
{
try
{
/* do work */
Thread.sleep( SLEEP_TIME); // let the other threads run.
}
catch( InterruptedException e ) { ... }
}
}
public class TestThread
{
public static main( )
{
Runable run = new myThread();
Thread thread=new Thread( run );
thread.start(); // will invoke myThread.run()
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: