Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace winConsole
{
class Program
{
static void function()
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine(i);
}
}
static void Main(string[] args)
{
Console.WriteLine("Main begin!");
ThreadStart ts = new ThreadStart(function);
Thread t = new Thread(ts);
t.Start();
Console.WriteLine("Main end!");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace winConsole
{
class Program
{
static void function()
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine(i);
}
}
static void Main(string[] args)
{
Console.WriteLine("Main begin!");
ThreadStart ts = new ThreadStart(function);
Thread t = new Thread(ts);
t.Start();
Console.WriteLine("Main end!");
}
}
}
先输出:
Main begin!
Main end!
再输出1...10