夜来无聊
class Program
{
static void Main(string[] args)
{
Thread th = new Thread(Print);
th.Start();
Console.Read();
}
static bool has;
static string code;
static bool stop;
static int a;
static Random rnd = new Random((int)DateTime.Now.Ticks);
public static void Print()
{
while (a < 10)
{
has = true;
if (has == true && stop == false)
{
code = Give();
Console.WriteLine(code);
has = false;
}
a++;
if (a == 10)
{
stop = true;
}
}
}
public static string Give()
{
int First = (int)'a';
int Last = (int)'z';
char[] chr = new char[4];
for (int i = 0; i < 4; i++)
{
int k = rnd.Next(First, Last);
chr[i] = (char)k;
}
string str = new string(chr);
return str;
}
}