Results 1 to 6 of 6

Thread: When to use Multithreading?

  1. #1
    Join Date
    Jan 2011
    Posts
    128
    Thanks
    2

    Default When to use Multithreading?

    So yeah,title says it all.
    I want to know what kind of program has it to be in order multithreading could be used,or in which cases it is necessary.

    For example I can make calc but there is no need of threads...

    thnx

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: When to use Multithreading?

    For example I can make calc but there is no need of threads...
    Why not?


    Now the message is not too short.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2011
    Posts
    128
    Thanks
    2

    Default Re: When to use Multithreading?

    Like what?
    I mean the program is quite small to adjust threads..wouldn't it slow it?

    I ask about bigger projects.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: When to use Multithreading?

    It depends what you calculate. If your calc does some fourier transform or some iterative problem solving threads could be useful.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: When to use Multithreading?

    Like what?
    I mean the program is quite small to adjust threads..wouldn't it slow it?
    Since you said the Calc as an example would not need threads, it points to it that you have an idea when threads are not needed (which means, that if you use the opposite to these reasons you would know when thread are needed).
    But I wanted to see why you think threads are not needed for Calc.

    When one should use threads has nothing to do with the size of the project, but with what and how the application needs to do.
    There is no cook-book recipe answer to this.
    One example that comes very often is:
    If you have a very long operation that needs to be done, and you have a gui too, it makes sense to but the long operation in a separate thread, so that the GUI stays responsive.
    Or, when you need asynchronous behavior.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. #6
    Join Date
    Apr 2011
    Posts
    124
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Re: When to use Multithreading?

    There are basically two cases where multi-threading is usefull and effective:

    1) You need to accomplish some long-running activity without impacting the responsiveness of the rest of the application.

    2) You have several conceptually linear activities that you want to occur simultaneously, possibly with interaction between them at selected places.

    There are ways (eg, the ever-popular "event loop") to do the above without multi-threading, but multi-threading can (in skilled hands) be a more elegant, efficient, and reliable way to do it. In poorly skilled hands multi-threading can be an utter disaster, though.

Similar Threads

  1. QThread for Multithreading
    By strateng in forum Newbie
    Replies: 12
    Last Post: 8th June 2010, 14:32
  2. regarding multithreading
    By mohanakrishnan in forum Qt Programming
    Replies: 19
    Last Post: 9th December 2009, 09:21
  3. multithreading
    By mickey in forum General Programming
    Replies: 2
    Last Post: 5th June 2008, 23:01
  4. MultiThreading in Qt
    By manivannan_1984 in forum Qt Programming
    Replies: 7
    Last Post: 7th November 2006, 20:26
  5. MultiThreading n Qhttp
    By Shambhavi in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2006, 14:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.