[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()
}
}
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()
}
}
相关文章推荐
- 关于javascript程序内存占用的一个有趣的实验
- JavaScript:多图片变化且每次的效果不同
- 我的第一段未使用 document.all.obj 的JS
- JavaScript经常用到的17种正则表达式
- 禁止html页面中的缓存
- 在blog中显示天气预报、日历、时钟、MSN、QQ在线状态、中国农历
- JScript错误代码及相应解释大全
- 值得收藏的一些HTML、JavaScript、ASP代码
- 一些实用的javascript代码(转载)
- JavaScript 参考教程
- TBanner in JScript
- 给任何控件添加链接功能(原创)
- Effective Java 学习笔记(三)
- 网页设计技巧11则
- 常用的Javascript检测函数[zz]
- 值得收藏的一些HTML、JavaScript、ASP代码
- JavaScript 对象与数组参考大全
- 面向对象的Javascript语言
- 细节问题:Java中语法深度透析,以混淆的javascriptlet
- Which to Prefer: to Leave or Stay in the National Enterprises