Thread

Bom dia, antes eu utilizava o Cobol isCobol e lá temos a instrução "perform thread" essa instrução faz com que desvie o fluxo do programa para uma rotina e fique executando outra ao mesmo tempo como fazer com Visual Cobol, obrigado.

Good day, before I used the Cobol isCOBOL and there we have the statement " perform thread" this statement causes divert the program flow to a routine and stay running another at the same time how to make Visual Cobol , thank you.

Parents
  • The perform thread syntax is not supported in Visual COBOL.

    Multi-threading can be done using a variety of methods. There is an entire  section in the documentation devoted to this topic. It can be found here:

    In addition to the threading syntax and callable library routines available, in managed code you can also use the Threading class to start up additional threads.

    Example:

          $set ilusing"System"
          $set ilusing"System.Threading"
           program-id. Program1 as "testthreading.Program1".
    
           data division.
           working-storage section.
    
           procedure division.
               declare thread1 as type Thread
               declare threadDelegate as type ThreadStart = new ThreadStart(type ThreadWork::DoWork)
               set thread1 to new Thread(threadDelegate)
               invoke thread1::Start
               perform varying i as binary-long from 0 by 1 until i > 3
                  display "In Main"
                  invoke type Thread::Sleep(100)
               end-perform
               goback.
               
           end program Program1.
           class-id ThreadWork.
           working-storage section.
           
           method-id DoWork static.
           procedure division.
               perform varying i as binary-long from 0 by 1 until i > 3
                  display "Working Thread..."
                  invoke type Thread::Sleep(100)
               end-perform
              
               goback.
           end method.
           
           end class.
          
Reply
  • The perform thread syntax is not supported in Visual COBOL.

    Multi-threading can be done using a variety of methods. There is an entire  section in the documentation devoted to this topic. It can be found here:

    In addition to the threading syntax and callable library routines available, in managed code you can also use the Threading class to start up additional threads.

    Example:

          $set ilusing"System"
          $set ilusing"System.Threading"
           program-id. Program1 as "testthreading.Program1".
    
           data division.
           working-storage section.
    
           procedure division.
               declare thread1 as type Thread
               declare threadDelegate as type ThreadStart = new ThreadStart(type ThreadWork::DoWork)
               set thread1 to new Thread(threadDelegate)
               invoke thread1::Start
               perform varying i as binary-long from 0 by 1 until i > 3
                  display "In Main"
                  invoke type Thread::Sleep(100)
               end-perform
               goback.
               
           end program Program1.
           class-id ThreadWork.
           working-storage section.
           
           method-id DoWork static.
           procedure division.
               perform varying i as binary-long from 0 by 1 until i > 3
                  display "Working Thread..."
                  invoke type Thread::Sleep(100)
               end-perform
              
               goback.
           end method.
           
           end class.
          
Children
No Data