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()
}
}
本文地址:http://com.8s8s.com/it/it12762.htm