public static void main(String args[]) throws IOException
{
Process p = Runtime.getRuntime().exec("java E:/workspace/JNIProgram/src/JNIProgram.class");
}
Run Code Online (Sandbox Code Playgroud)
所以我有这个代码,我正在尝试运行JNIProgram.class文件,但程序立即终止而不做其工作(这是创建一个新的txt文件并写入它)
那么我做错了什么
我有一些代码可以利用并行性来提高效率.由于我的PC有双处理器,我尝试在两个线程上运行代码.所以我写了下面的代码(这是一个非常简化的版本):
Evaluator::evaluate(vector<inpType> input, bool parallel) {
std::thread t0;
if(parallel) {
// Evaluate half of the input in a spawned thread
t0 = std::thread(&Evaluator::evaluatePart, this, std::ref(input), 0, input.size()/2 + input.size()%2);
// Evaluate the other half of the input in this thread
evaluatePart(input, input.size()/2 + input.size()%2 - 1, input.size()/2);
} else {
// sequential evaluate all of the input
evaluatePart(input, 0, input.size());
}
// some other code
// after finishing everything join the thread
if(parallel) t0.join();
}
Evaluator::evaluatePart(vector<inpType> &input, int start, int …Run Code Online (Sandbox Code Playgroud)