Pytorch中变量的volatile属性是什么?这是一个用于在PyTorch中定义变量的示例代码.
datatensor = Variable(data, volatile=True)
Run Code Online (Sandbox Code Playgroud) 我想使用std::thread像这样的库在C++中创建嵌套线程.
#include<iostream>
#include<thread>
#include<vector>
using namespace std;
void innerfunc(int inp)
{
cout << inp << endl;
}
void outerfunc(int inp)
{
thread * threads = new thread[inp];
for (int i = 0; i < inp; i++)
threads[i] = thread(innerfunc, i);
for (int i = 0; i < inp; i++)
threads[i].join();
delete[] threads;
}
int main()
{
int inp = 0;
thread t1 = thread(outerfunc,2);
thread t2 = thread(outerfunc,3);
t1.join();
t2.join();
}
Run Code Online (Sandbox Code Playgroud)
我可以安全地这样做吗?我担心是否join()正常工作.