C++ 对象可以有块作用域吗?例如,这样可以吗:(它崩溃了)
(放轻松,我还在学习 C++)
__block Poco::Thread* lastThread;
dispatch_async(dispatch_get_main_queue(), ^
{
for (int i = 1; i <= 5; i++)
{
Poco::Runnable* worker = new Worker(_counter, "worker" + Poco::NumberFormatter().format(i));
Poco::Thread* workerThread = new Poco::Thread();
workerThread->start(*worker);
lastThread = workerThread;
}
});
lastThread->join(); //wait so we can watch what happens.