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.