Program
Program
{
internal class Program
{
static int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 , 11 , 12};
static int sum = 0;
static object lockObject = new object();
static int halfway = numbers.Length / 2;
static MymathLib mymathLibobj = new MymathLib();
static void Main(string[] args)
{
class MymathLib
{
public int Numb1;
public int Numb2;
Random randnumb = new Random();
static object lockObject = new object();
public MymathLib() {
Console.WriteLine("some running the other method");
Console.WriteLine($"the other method thread
{Thread.CurrentThread.ManagedThreadId}");
}
public void Divide() {
for(int i = 0; i < 100000; i++)
{
lock (lockObject)
{ //safe thread objects.
Numb1 = randnumb.Next(1,2);
Numb2 = randnumb.Next(1,2);