There are 2 classes
class A : class Parent { public void Draw() } class B : class Parent { public void Draw() } And you need to synchronize these 2 threads so that the methods are executed strictly in turn. (or at least to the end) The Parent class has a synchronization object. The Draw method is implemented like this.
public void Draw() { while(true) { lock(obj) { //Рисуем объект } } } As it seemed to me, the threads should have been executed, albeit not alternately, but until the end, only after that, another thread had to start (or the same). In fact, it turns out that the processes interfere with each other
class Parent { public object obj = new object(); } Class with threads:
class Game { public void Start() { A first = new A(); B second = new B(); Thread doRoad = new Thread(A.Draw); Thread doAuto = new Thread(B.Draw); A.Start(); B.Start(); } }
obj? It is important. - VladD