开发者

Moving a function in a running thread to a new thread?

I have a read and write function in a class file. this class subclasses QThread class and overrides run, does not have signals and slots ,It basically runs data processing functions in a threa开发者_如何学编程d. in its constructor is the method movetothread(this). To have the two functions to form a queue and implement muli-threading , can i make a movetothread(secondthread) call in the write function?

void write(args)
{
 movetothread(secondthread);
}

to make the write function run on a separate thread. How and when does the write function stop?.


It doesn't work that way. QObject::moveToThread associates the object with another thread, not the calling function. Furthermore, this affects future event processing only.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜