Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Process and thread are not Qt-specific concepts. You can search for "process vs. thread" anywhere for that distinction to be explained. For instance: <a href="https://stackoverflow.com/questions/1762418/process-vs-thread">What resources are shared between threads?</a></p> <p>Though related concepts, spawning a new process is a more "heavyweight" form of parallelism than spawning a new thread within your existing process. Processes are protected from each other by default, while threads of execution <em>within</em> a process can read and write each other's memory directly. The protection you get from spawning processes comes at a greater run-time cost...and since independent processes can't read each other's memory, you have to share data between them using methods of <a href="http://en.wikipedia.org/wiki/Inter-process_communication" rel="nofollow noreferrer">inter-process communication</a>.</p> <p>Odds are that you want threads, because they're simpler to use in a case where one is writing all the code in a program. Given all the complexities in multithreaded programming, I'd suggest looking at a good book or reading some websites to start with. See: <a href="https://stackoverflow.com/questions/2482/what-are-some-good-resources-for-learning-threaded-programming">What are some good resources for learning threaded programming?</a></p> <p>But if you want to dive in and just get a feel for how threading in Qt looks, you can spend time looking at the examples:</p> <p><a href="http://qt-project.org/doc/qt-4.8/examples-threadandconcurrent.html" rel="nofollow noreferrer">http://qt-project.org/doc/qt-4.8/examples-threadandconcurrent.html</a></p> <p>QtConcurrent is an abstraction library that makes it easier to implement some kinds of parallel programming patterns. It's built on top of the QThread abstractions, and there's nothing it can do that you couldn't code yourself by writing to QThread directly. But it might make your code easier to write and less prone to errors.</p> <p>As for an event loop...that is merely a generic term for how any given thread of execution in your program waits for work items to process, processes them, and can decide when it is no longer needed. If a thread's job were merely to start up, do some math, and exit...then it wouldn't need an event loop. But starting and stopping a thread takes time and churns resources. So typically threads live for longer periods of time, and have an event loop that knows how to wait for events it needs to respond to.</p> <p>If you build on top of QtConcurrent, you won't have to worry about an event loop in your worker threads because they are managed automatically in a thread pool. The word count example is pretty simple to see:</p> <p><a href="http://qt-project.org/doc/qt-4.8/qtconcurrent-wordcount-main-cpp.html" rel="nofollow noreferrer">http://qt-project.org/doc/qt-4.8/qtconcurrent-wordcount-main-cpp.html</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload