static void Main(string[] args) { IncThread myt1 = new IncThread(); DecThread myt2 = new DecThread(); Console.Read(); }
public static void Demo3() { IncThread mthrd1 = new IncThread("IncThread thread ", 5); DecThread mthrd2 = new DecThread("DecThread thread ", 5); mthrd1.Thrd.Join(); mthrd2.Thrd.Join(); }
static void Main() { // Construct two threads. IncThread mt1 = new IncThread("Increment Thread"); DecThread mt2 = new DecThread("Decrement Thread"); mt1.Thrd.Join(); mt2.Thrd.Join(); }
static void Main() { // Construct three threads. IncThread mt1 = new IncThread("Increment Thread", 5); Thread.Sleep(1); // let the Increment thread start DecThread mt2 = new DecThread("Decrement Thread", 5); mt1.Thrd.Join(); mt2.Thrd.Join(); }
static void Main() { var mt1 = new IncThread("Инкрементирующий", 5); Thread.Sleep(1); var mt2 = new DecThread("Декрементирующий", 3); mt1.Thrd.Join(); mt2.Thrd.Join(); }
public static void MutexTest() { // Сконструировать два потока IncThread mt1 = new IncThread("IncThread", 5); // Разрешить инкрементируемому потоку начаться Thread.Sleep(1); DecThread mt2 = new DecThread("DecThread", 5); mt1.Thrd.Join(); mt2.Thrd.Join(); }
public void Main() { var mt1 = new IncThread("Inc thread", 5); // разрешить инкременирующему потоку начаться Thread.Sleep(1); var mt2 = new DecThread("Dec thread", 5); mt1.Thrd.Join(); mt2.Thrd.Join(); Console.ReadLine(); }
static void Main(string[] args) { IncThread mt1 = new IncThread("IncStream", 5); DecThread mt2 = new DecThread("DecStream", 5); mt1.Thrd.Join(); mt1.Thrd.Join(); Console.WriteLine("Threads done"); IncThreadNM Nmt1 = new IncThreadNM("IncStreamNM", 5); DecThreadNM Nmt2 = new DecThreadNM("DecStreamNM", 5); mt1.Thrd.Join(); mt1.Thrd.Join(); Console.WriteLine("NMThreads done"); }
public virtual void TestStressTryIncRef() { Directory dir = NewDirectory(); IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()))); writer.AddDocument(new Document()); writer.Commit(); DirectoryReader r = DirectoryReader.Open(dir); int numThreads = AtLeast(2); IncThread[] threads = new IncThread[numThreads]; for (int i = 0; i < threads.Length; i++) { threads[i] = new IncThread(r, Random()); threads[i].Start(); } Thread.Sleep(100); Assert.IsTrue(r.TryIncRef()); r.DecRef(); r.Dispose(); for (int i = 0; i < threads.Length; i++) { threads[i].Join(); Assert.IsNull(threads[i].Failed); } Assert.IsFalse(r.TryIncRef()); writer.Dispose(); dir.Dispose(); }