How to resolve the algorithm Concurrent computing step by step in the FreeBASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Concurrent computing step by step in the FreeBASIC programming language

Table of Contents

Problem Statement

Using either native language concurrency syntax or freely available libraries, write a program to display the strings "Enjoy" "Rosetta" "Code", one string per line, in random order. Concurrency syntax must use threads, tasks, co-routines, or whatever concurrency is called in your language.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Concurrent computing step by step in the FreeBASIC programming language

Source code in the freebasic programming language

' FB 1.05.0 Win64
' Compiled with -mt switch (to use threadsafe runtiume)
' The 'ThreadCall' functionality in FB is based internally on LibFFi (see [https://github.com/libffi/libffi/blob/master/LICENSE] for license)

Sub thread1()
  Print "Enjoy"
End Sub

Sub thread2()
  Print "Rosetta"
End Sub

Sub thread3()
  Print "Code"
End Sub

Print "Press any key to print next batch of 3 strings or ESC to quit"
Print

Do
  Dim t1 As Any Ptr = ThreadCall thread1
  Dim t2 As Any Ptr = ThreadCall thread2
  Dim t3 As Any Ptr = ThreadCall thread3
  ThreadWait t1
  ThreadWait t2
  ThreadWait t3
  Print
  Sleep
Loop While Inkey <> Chr(27)

  

You may also check:How to resolve the algorithm CSV to HTML translation step by step in the UNIX Shell programming language
You may also check:How to resolve the algorithm Sorting algorithms/Insertion sort step by step in the R programming language
You may also check:How to resolve the algorithm Check that file exists step by step in the Ada programming language
You may also check:How to resolve the algorithm Ternary logic step by step in the J programming language
You may also check:How to resolve the algorithm Multiple distinct objects step by step in the Action! programming language