using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Collections;
namespace @try
{
public partial class Form1 : Form
{
ArrayList al = new ArrayList();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
newThread nt = new newThread(DateTime.Now);
listBox1.Items.Add(nt.dtback());
al.Add(nt);
count++;
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
string s="现在已经启动线程"+count+"个";
MessageBox.Show(s);
foreach (newThread nT in al)
{
MessageBox.Show(nT.dtback().ToString());
}
}
}
public class newThread
{
private DateTime dt;
private Thread chck;
public DateTime dtback()
{
return dt;
}
public ref Thread Threadback()
{
return this.chck;
}
public newThread(DateTime t)
{
dt = t;
chck = new Thread(new ThreadStart(Check));
chck.Start();
}
public void Check()
{
MessageBox.Show("线程创建时间为:"+this.dt);
}
}
}