Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What high level languages support multithreading? [closed]

I'm wondering which languages support (or don't support) native multithreading, and perhaps get some details about the implementation. Hopefully we can produce a complete overview of this specific functionality.

like image 828
bmdhacks Avatar asked Sep 26 '08 17:09

bmdhacks


People also ask

Which programming languages support multithreading?

C/C++ Languages Now Include Multithreading Libraries Programming languages, such as C and C++, have evolved to make it easier to use multiple threads and handle this complexity. Both C and C++ now include threading libraries.

Does C++ allow multi-threading?

C++ multithreading involves creating and using thread objects, seen as std::thread in code, to carry out delegated sub-tasks independently. New threads are passed a function to complete, and optionally some parameters for that function.

Does C and C++ support multithreading?

The Microsoft C/C++ compiler (MSVC) provides support for creating multithread applications. Consider using more than one thread if your application needs to perform expensive operations that would cause the user interface to become unresponsive.

Does Python allow multi-threading?

Both multithreading and multiprocessing allow Python code to run concurrently. Only multiprocessing will allow your code to be truly parallel. However, if your code is IO-heavy (like HTTP requests), then multithreading will still probably speed up your code.


3 Answers

Erlang has built-in support for concurrent programming.

Strictly speaking, Erlang processe are greenlets. But the language and virtual machine are designed from the ground up to support concurrency. The language has specific control structures for asynchronous inter-process messaging.

In Python, greenlet is a third-party package that provides lightweight threads and channel-based messaging. But it does not bear the comparison with Erlang.

like image 184
ddaa Avatar answered Oct 13 '22 23:10

ddaa


I suppose that the list of languages that are higher-level than Haskell is pretty short, and it has pretty good support for concurrency and parallelism.

like image 34
Chris Vest Avatar answered Oct 13 '22 23:10

Chris Vest


With CPython, one has to remember about the GIL. To summarize: only one processor is used, even on multiprocessor machines. There are multiple ways around this, as the comment shows.

like image 23
Adriano Varoli Piazza Avatar answered Oct 13 '22 23:10

Adriano Varoli Piazza