Корректность кода - C#
Формулировка задачи:
Опытные, гляньте одним глазом. Правильно ли пишу.
Program.cs
Class1.cs
Class2.cs
using System;
using System.Threading;
namespace Ex5
{
class Program
{
public static string txt = "январь февраль март апрель май июнь июль август сентябрь октябрь ноябрь декабрь";
public static string[] splitarr = null;
static void Main()
{
splitarr = txt.Split(' ');
Console.Write(" {0}", splitarr[0]+' '+splitarr[1]+' '+splitarr[2]);
Console.WriteLine();
Class1 Thr1 = new Class1();
Thr1.thread1.Join();
Console.ReadKey();
}
}
}using System;
using System.Threading;
namespace Ex5
{
public class Class1
{
public Thread thread1;
public Class1()
{
thread1 = new Thread(Rab);
thread1.Start();
}
public void Rab()
{
lock (this)
{
Console.Write(" {0}", Program.splitarr[3]+' '+Program.splitarr[4]+' '+Program.splitarr[5]);
Console.WriteLine();
Class2 Thr2 = new Class2();
Thr2.thread2.Join();
}
}
}
}using System;
using System.Threading;
namespace Ex5
{
public class Class2
{
public Thread thread2;
public Class2()
{
thread2 = new Thread(Rab);
thread2.Start();
}
public void Rab()
{
lock (this)
{
Console.Write(" {0}", Program.splitarr[6]+' '+Program.splitarr[7]+' '+Program.splitarr[8]);
Console.WriteLine();
}
}
}
}Решение задачи: «Корректность кода»
textual
Листинг программы
static string[] txt = {"январь","февраль","март","e.t.c"};