We are running a long job (function) in 3-4 different threads. All running threads got successfully completed but sometimes the exception Thread was being aborted
is being thrown by one of the thread which results all threads to stop. Below is sample code for what we are actually doing in our application.
List<Thread> lstThreads = new List<Thread>();
foreach(int 0; i < 4; i++)
{
Thread th = new Thread(() => {
RunLongRunningJob(i);
});
lstThreads.Add(th);
}
foreach (Thread th in lstThreads)
th.Start();
We are calling rest api's, writing in files and update database records in RunLongRunningJob
.
P.S. We are not using LOCKS, is this could be the reason?