As I said in a comment, you should no longer manage threads. Always use dispatch_queue instead of threads.
If you really want to do this, here is a workaround: CFRunLoopPerformBlock .
This is C code, but I think you can translate it into Swift code without much difficulty.
CFRunLoopRef myrunloop;
void worker_thread_main() {
myrunloop = CFRunLoopGetCurrent();
CFRunLoopRun();
}
CFRunLoopPerformBlock(myrunloop, kCFRunLoopCommonModes, ^{
dowork();
});
source
share