我有非常大的文件,我必须阅读和处理.这可以使用线程并行完成吗?
这是我做过的一些代码.但它似乎没有得到更短的执行时间读取和处理文件一个接一个.
String[] files = openFileDialog1.FileNames;
Parallel.ForEach(files, f =>
{
readTraceFile(f);
});
private void readTraceFile(String file)
{
StreamReader reader = new StreamReader(file);
String line;
while ((line = reader.ReadLine()) != null)
{
String pattern = "\\s{4,}";
foreach (String trace in Regex.Split(line, pattern))
{
if (trace != String.Empty)
{
String[] details = Regex.Split(trace, "\\s+");
Instruction instruction = new Instruction(details[0],
int.Parse(details[1]),
int.Parse(details[2]));
Console.WriteLine("computing...");
instructions.Add(instruction);
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 为什么我收到此错误?我没有任何外键
drop table if exists t_issue;
SET foreign_key_checks = 0;SET storage_engine=INNODB;
CREATE TABLE `t_issue` (
`id_issue` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`fk_project` int(11) DEFAULT NULL,
`subject` varchar(255) DEFAULT NULL,
`estimated_due_date` date DEFAULT NULL,
`due_date` date DEFAULT NULL,
`done_ratio` int(11) DEFAULT NULL,
`fk_status` int(11) DEFAULT NULL,
`fk_assigned_to` int(11) DEFAULT NULL,
`fk_owner` int(11) DEFAULT NULL
) ENGINE=innodb DEFAULT CHARSET=latin1
Run Code Online (Sandbox Code Playgroud) 我试图通过使用删除本地存储库中的最后一个提交
git reset --hard HEAD~1
Run Code Online (Sandbox Code Playgroud)
命令.但是我收到以下错误:
fatal: Could not reset index file to revision 'HEAD~1'.
Run Code Online (Sandbox Code Playgroud)
我明白了
(Filename too long)
Run Code Online (Sandbox Code Playgroud)
对于几个文件.我怎么能避免这个?我在Windows上
我使用 Maven Surefire 插件来运行一组特定的测试。例如:
package suite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import suite.slow.EvenSlowerClassTest;
import suite.slow.SlowClassTest;
@RunWith(Suite.class)
@Suite.SuiteClasses({
SlowClassTest.class,
EvenSlowerClassTest.class
})
public class SlowSuite {
}
Run Code Online (Sandbox Code Playgroud)
通过使用maven命令
test -DrunSuite=**/FastSuite.class -DfailIfNoTests=false
Run Code Online (Sandbox Code Playgroud)
我可以显式运行 FastSuite 或 SlowSuite 测试套件,但是,如何运行我拥有的所有测试套件或测试套件中未涵盖的所有测试?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>${runSuite}</include>
</includes>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud) 有人能举例说明如何在Extjs中使用XTemplate来包含特定的css类吗?
<tpl if="total > 5000">
yellow css
<tpl else>
red css
</tpl>
Run Code Online (Sandbox Code Playgroud)
编辑: 我有这样的事情
new Ext.XTemplate('<span style="display:inline-block; margin-right: 730px;"">' + title + ' ({count}) </span>',
'<span ',
'<tpl if="priceTotal > 5000"> style="color:black;" class="x-form-item-label x-form-warning"</tpl>',
'> {priceTotalLabel}: {priceTotal}',
'</span>'
);
Run Code Online (Sandbox Code Playgroud)
我想用变量中的值替换值5000,所以它不是硬编码的,我该怎么做?
我创建了一个Thread,我只需要从表单的左侧移动一个radiobutton.这运行,但我的应用程序被阻止,我无法移动表单,没有(我认为这是创建线程的原因,同时做多个事情)这是我的代码,我希望你明白我问.提前致谢
private void moveRight( )
{
radioButton1.Left++;
}
private void moveLeft()
{
radioButton1.Left--;
}
public void run()
{
while (true)
{
while (radioButton1.Left != this.ClientSize.Width - 10)
{
if (InvokeRequired)
{
Invoke(new MethodInvoker(moveRight));
}
else
{
moveRight();
}
}
while (radioButton1.Left != 10)
{
if (InvokeRequired)
{
Invoke(new MethodInvoker(moveLeft));
}
else
{
moveLeft();
}
}
}
}
private void button1_Click(object sender, EventArgs e)
{
t = new Thread(new ThreadStart(run));
t.Start();
}
Run Code Online (Sandbox Code Playgroud) 设置依赖项时.我们假设如下
<dependency>
<groupId>com.atlassian.plugins</groupId>
<artifactId>atlassian-plugins-osgi-testrunner</artifactId>
<version>${plugin.testrunner.version}</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
在哪里
${plugin.testrunner.version}
Run Code Online (Sandbox Code Playgroud)
变量初始化?是否有属性文件或它获取值的位置?
如果我在Eclipse或其他git客户端上添加拒绝推送的挂钩,则会显示拒绝消息.
但是,如果我使用intelij-idea,则不会显示拒绝原因.
这可以配置为在JIdea中显示吗?
这段代码导致IndexOutOfBoundsException任何人都可以告诉我为什么?我无法理解它导致IndexOutOfBoundsException的原因
private static String TRACE_PATH = "..\\..\\TRACES";
static void Main(string[] args)
{
if (Directory.Exists(TRACE_PATH))
{
String[] traceEntries = Directory.GetFiles(TRACE_PATH);
Thread[] traceReaders = new Thread[traceEntries.Length];
for (int i = 0; i < traceEntries.Length; i++)
{
traceReaders[i] = new Thread(()=>readTrace(traceEntries[i]));
traceReaders[i].Start();
}
}
Console.Read();
}
private static void readTrace(String traceFile)
{
using (StreamReader sr = new StreamReader(traceFile))
{
//code to use the trace file...
}
}
Run Code Online (Sandbox Code Playgroud)