- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在创建一个对输入执行顺序处理的组件。因为它将托管在几个不同的进程中,所以我需要它是线程安全的。起初,我故意在代码中忽略了线程安全。现在是介绍它的时候了。
首先,我想引发一个错误,但未能成功。这是处理引擎代码的简化版本:
public Document DoOrchestration(Document input)
{
Document output = new Document();
foreach (var orchestrationStep in m_OrchestrationSteps)
{
var processor = GetProcessor(orchestrationStep).Clone();
output = processor.Process(input);
input = output;
}
return output;
}
处理器可以由我组织中的其他人开发,并且可以包括一些复杂的初始化。它们也可能是线程不安全的,因此我使用原型(prototype)模式来获取 的唯一实例,以避免其中出现线程问题。
为了测试此功能,我使用了以下代码:
for (int i = 0; i < 20000; i++)
{
Thread t = new Thread(() => TestOrchestration(i));
t.Start();
}
void TestOrchestration(int number)
{
Document doc = new Document(string.Format("Test {0}", number));
doc = DoOrchestration(doc);
if (doc.ToString().Substring(0,35) != strExpectedResult)
{
System.Console.WriteLine("Error: {0}", doc.ToString();
}
}
我预计某些线程会与另一个线程发生冲突并混淆它们的结果,但令我惊讶的是这并没有发生。
对此可能有一个简单而合乎逻辑的解释,但它让我难以理解。或者只是代码太简单导致两个线程同时摆弄输入/输出变量?
最佳答案
查看 CHESS .
CHESS is a tool for finding and reproducing Heisenbugs in concurrent programs. CHESS repeatedly runs a concurrent test ensuring that every run takes a different interleaving. If an interleaving results in an error, CHESS can reproduce the interleaving for improved debugging. CHESS is available for both managed and native programs.
关于c# - 如何激发对共享资源的同时访问?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12968559/
我最近想将 Cython 与 Spark 一起使用,为此我关注了 the following reference . 我写了下面提到的程序,但我得到了: TypeError: fib_mapper_c
我目前拥有它,因此当单击链接时我的标题会滑入。如何做到(当单击链接时)当前标题会在新标题滑入之前滑出? 这是我一直在使用的clicked事件。这可能很奇怪,我一直在添加不同的东西来尝试让它工作。 //
我正在编写一个使用 kubernetes 而不是 yarn 的 spark 作业。 val spark = SparkSession.builder().appName("Demo").master(
我已成功实现客户端/服务器 Android GCM 应用程序。我的应用服务器拥有一个 device/registration_id 对的数据库。消息通过 Web 可访问的 PHP 页面发送到设备。我正
我正在使用 iTunes Connect 中的新测试版功能。我将一个构建 (98) 上传到 iTunes Connect,设置了一些内部测试人员,他们下载了该构建。 现在我已经用新版本(build 9
我是一名优秀的程序员,十分优秀!