Does Racket support multithreading?

I want to write a multi-threaded program in Racket that actually uses several processes with shared memory space, for example pthread in C. Racket provides a "thread" but uses only one process to execute multiple threads. It also provides a “subprocess” for executing new programs through a command line that runs on several processes, but these programs cannot use the same memory space.

+4
source share
1 answer

Do not do that.

Racket does provide parallelism through futures and places , but they do not provide (unlimited) shared memory spaces. If you want to send data from one stream to another, use the place channel.

As Greg Hendershott points out, you can send a common vector through a place channel that provides a common space to use. (But this is not the same as sharing all memory references, which might mean someone familiar, for example, with Java-style threads. And the last is what my “don't do” refers to.)

If you really want to use pthread-like threading, Guile does provide them , but then you will no longer use Racket .; -)

+4

Source: https://habr.com/ru/post/1546076/


All Articles