Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. run two thread or two code line in same time

run two thread or two code line in same time

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 666 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alexanov
    wrote on last edited by Alexanov
    #1

    Hi I have create two thread classes :

     1-qprocessThread 
     2-qprocessThreadTwo
    

    Then in main class I have create two object from above thread classes like below :

        qprocessThread mythread;
        qprocessThreadTwo mythreadtwo;
    

    My question is that, how can run two code line below in the same time or synchronize ?

    mythread.initialize(File);
    mythreadtwo.initialize(File);
    

    I want to both of lines, run or start in the same time. How can I do this???

    jsulmJ 1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      You need to call start() method of both the thread object. There is nothing like both at same time. start() call has to be one after the other from calling/main thread.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      1
      • A Alexanov

        Hi I have create two thread classes :

         1-qprocessThread 
         2-qprocessThreadTwo
        

        Then in main class I have create two object from above thread classes like below :

            qprocessThread mythread;
            qprocessThreadTwo mythreadtwo;
        

        My question is that, how can run two code line below in the same time or synchronize ?

        mythread.initialize(File);
        mythreadtwo.initialize(File);
        

        I want to both of lines, run or start in the same time. How can I do this???

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Alexanov You should learn how multi-threading works: http://doc.qt.io/qt-5/thread-basics.html
        https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        3

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved