How to automatically make about 500,000 nameless streams and automatically start them and delete later? Automatically, of course.

  • one
    It should be at least superficially acquainted with the materiel before asking a question. - ruvim
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

Named threads do not exist. The stream is automatically "deleted" upon completion.

The lexicon of working with streams is not fixed in any standard of the Fort. Regarding SP-Forth / 4 - see the example in the documentation . It should be noted that the word TASK: creates a "task" (and not a thread).

An arbitrary word can be run in a separate thread by the word LAUNCH ( xt -- ) , which is defined as follows:

 :NONAME ( xt -- ) CATCH ERROR ; TASK CONSTANT LAUNCHER : LAUNCH ( xt -- ) \ xt ( -- ) LAUNCHER START CloseHandle ERR THROW ; \ пример : t 5 0 DO I . 200 PAUSE LOOP ; : test 3 0 DO ['] t LAUNCH 150 PAUSE LOOP ; test 

When parallelizing the calculation, the number of threads should be correlated with the number of processor cores. And in the general case - with the amount of RAM, because each stream has at least its own stack (roughly, 1 MB) - 5e5 threads is 0.5 terabytes of RAM.