Chenna V
Chenna V

Reputation: 10473

QThreads Vs Pthreads

I have a quick question. I am supposed to create a small multithreaded program to grab data from multiple sensors and I have knowledge of both pthreads and qthreads. I have access to both libraries. Personally I am biased towards using Qt because of its design and various functionalities. But is there a significant advantage on using one vs the other? Thanks

Upvotes: 10

Views: 7699

Answers (3)

peoro
peoro

Reputation: 26060

QThreads are built upon pthreads. They provide an Object Oriented abstraction, making it easier to work with threads. Besides QThreads are portable, they can run on whatever system using the underlying thread system, while pthreads are specific of POSIX systems.

The almost-only disadvantage of using QThreads is that you'll need to link your application against Qt; this dependence could make it a little more difficult to distribute your application.

Upvotes: 11

Eugene
Eugene

Reputation: 51

But you have to know what QThreads use event loop for managment it, so you can't just kill thread like with pthread. If threads do long and hard work, it's not possible to stop it while it not to be released. In some case it's important.

Upvotes: 5

Arnold Spence
Arnold Spence

Reputation: 22272

I think at the heart of things, QThread under linux uses pthread. I'm not sure what is under the hood for the Windows side of it. Unless there are some some specific pthread API functions that you need that aren't available with QThread, I would stick with QThread just to benefit from the portability that it will give you. I wouldn't expect there to be any significant performance difference. Qthread will also allow you to use the signal/slot mechanism across thread boundaries.

Upvotes: 2

Related Questions