本文整理汇总了C#中Lucene.Net.Support.ThreadClass.Join方法的典型用法代码示例。如果您正苦于以下问题:C# ThreadClass.Join方法的具体用法?C# ThreadClass.Join怎么用?C# ThreadClass.Join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Support.ThreadClass
的用法示例。
在下文中一共展示了ThreadClass.Join方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestIntermediateClose
public virtual void TestIntermediateClose()
{
Directory dir = NewDirectory();
// Test can deadlock if we use SMS:
IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMergeScheduler(new ConcurrentMergeScheduler()));
writer.AddDocument(new Document());
writer.Commit();
CountdownEvent awaitEnterWarm = new CountdownEvent(1);
CountdownEvent awaitClose = new CountdownEvent(1);
AtomicBoolean triedReopen = new AtomicBoolean(false);
//TaskScheduler es = Random().NextBoolean() ? null : Executors.newCachedThreadPool(new NamedThreadFactory("testIntermediateClose"));
TaskScheduler es = Random().NextBoolean() ? null : TaskScheduler.Default;
SearcherFactory factory = new SearcherFactoryAnonymousInnerClassHelper2(this, awaitEnterWarm, awaitClose, triedReopen, es);
SearcherManager searcherManager = Random().NextBoolean() ? new SearcherManager(dir, factory) : new SearcherManager(writer, Random().NextBoolean(), factory);
if (VERBOSE)
{
Console.WriteLine("sm created");
}
IndexSearcher searcher = searcherManager.Acquire();
try
{
Assert.AreEqual(1, searcher.IndexReader.NumDocs);
}
finally
{
searcherManager.Release(searcher);
}
writer.AddDocument(new Document());
writer.Commit();
AtomicBoolean success = new AtomicBoolean(false);
Exception[] exc = new Exception[1];
ThreadClass thread = new ThreadClass(() => new RunnableAnonymousInnerClassHelper(this, triedReopen, searcherManager, success, exc).Run());
thread.Start();
if (VERBOSE)
{
Console.WriteLine("THREAD started");
}
awaitEnterWarm.Wait();
if (VERBOSE)
{
Console.WriteLine("NOW call close");
}
searcherManager.Dispose();
awaitClose.Signal();
thread.Join();
try
{
searcherManager.Acquire();
Assert.Fail("already closed");
}
catch (AlreadyClosedException ex)
{
// expected
}
Assert.IsFalse(success.Get());
Assert.IsTrue(triedReopen.Get());
Assert.IsNull(exc[0], "" + exc[0]);
writer.Dispose();
dir.Dispose();
//if (es != null)
//{
// es.shutdown();
// es.awaitTermination(1, TimeUnit.SECONDS);
//}
}