小弟c#初学者,问一下各位大侠
using System;
using System.Threading;
namespace ThreadTest
{   
    public class Alpha    
    {      
        public void Beta()      
        {            for (int i = 0; ;i++ )
            {                Console.WriteLine("{0}", i);            }   
        }   
    };
    public class Simple
    {   
        public static int Main()   
        {        
            Console.WriteLine("Thread Start/Stop/Join Sample"); 
            Alpha oAlpha = new Alpha();    
            
            Thread oThread = new Thread(new ThreadStart(oAlpha.Beta));
            
            oThread.Priority = ThreadPriority.Highest;
                      oThread.Start();    
                       oThread.Abort();    
            
            Console.WriteLine();   
            Console.WriteLine("Alpha.Beta has finished");    
            Console.Read();              return 0; 
        }  
    }
}
这段程序怎么理解,我将 oThread.Priority 设为优先级最高,为什么有时输出
Thread Start/Stop/Join SampleAlpha.Beta has finished
Try to restart the Alpha.Beta thread

解决方案 »

  1.   

    oThread.Start(); 
    Thread.Join();  
    oThread.Abort();
      

  2.   

    但是我不大明白主线程的优先级不是normal吗,我将oThread的优先级设为最高,为什么没有执行oThread线程
      

  3.   

    线程Start之后马上又Abort了,Beta里面的循环能跑几次就不一定了,可能10次,也可能0次,不输出结果很正常。
      

  4.   

    不好意思,可能是我理解错误,但othread.abort不是主线程执行的吗,我将othread的优先级设为最高,不就它先去去执行吗