Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个由多个线程调用的 threadSafe 方法。有没有办法知道哪个线程调用了它?
好吧,您知道调用该方法的线程,并且通过扩展,同一线程将在该方法调用中处于活动状态。你可以打电话QThread::currentThread()来得到这个。
QThread::currentThread()
如果你需要它,你可以添加一个threadId参数,并让它线程将它传递给方法
threadId