简体   繁体   English

我怎么知道哪个线程叫方法

[英]How do I know which thread called a method

I have a threadSafe method that gets called by multiple threads. 我有一个被多个线程调用的threadSafe方法。 Is there a way to know which thread called it? 有没有办法知道哪个线程调用了它?

Well, you know the thread that calls the method, and by extension the same thread will be active inside that method call. 好吧,您知道调用该方法的线程,并且通过扩展,同一线程将在该方法调用内处于活动状态。 You can just call QThread::currentThread() to get this. 您可以只调用QThread::currentThread()来获取此信息。

如果需要,可以添加一个threadId参数,并将其传递给方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM