Answer the question
In order to leave comments, you need to log in
How to simplify (optimize) the code?
Good afternoon.
There is a code:
static void Main(string[] args)
{
Thread ThreadData1 = new Thread(new ThreadStart(fData1));
ThreadData1.IsBackground = true;
ThreadData1.Start();
Thread ThreadData2 = new Thread(new ThreadStart(fData2));
ThreadData2.IsBackground = true;
ThreadData2.Start();
Thread ThreadData3 = new Thread(new ThreadStart(fData3));
ThreadData3.IsBackground = true;
ThreadData3.Start();
ThreadData1.Join();
ThreadData2.Join();
ThreadData3.Join();
}
public static void fData1()
{
foreach (string l in Data1)
OptimizeIStage1(l, dataA);
}
public static void fData2()
{
foreach (string l in Data2)
OptimizeIStage2(l, dataB);
}
public static void fData3()
{
foreach (string l in Data3)
OptimizeIStage3(l, dataC);
}
Answer the question
In order to leave comments, you need to log in
No need to work with Thread , take Task and everything will be much better
Get rid of copypasta first
private Thread GetThreadData(ThreadStart startData)
{
Thread result = new Thread(startData);
result.IsBackground = true;
result.Start();
return result;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question