0

In my CS class we're discussing threads and processes. I'm curious to know what common programming languages (Java, C/C++, C#, Python) can actually implement multi-threading and, if they do, how efficiently they do it.

We were shown a simple multi-threading structure in C but they didn't demonstrate the difference by running it or by a chart of collected results from a previous test. I assume that the gains for some languages using multi-threading may be negligible

EDIT

PDizzle pointed out that the gains in efficiency isn't necessarily dependent upon the language but rather what the applications/software in question require, as well as how well it is implemented for said application/software

Kamikaze Rusher
  • 271
  • 2
  • 10
  • The best gains come from having atomic operations carried out by the thread. ie.web crawling would be a good example. Pass the processing for each page off to a individual thread. – markbernard Jan 30 '15 at 21:11
  • This question is far too broad in scope. Define *common programming languages*, and define the scale of *efficiently*. – Ken White Jan 30 '15 at 21:12
  • I understand that you can multi-process, but not multi-thread in python. http://stackoverflow.com/questions/2846653/python-multithreading-for-dummies – Chris Desjardins Jan 30 '15 at 23:05

2 Answers2

2

When a program creates a separate thread for processing, it all boils down to the program making a call to the operating system to request resources for a thread.

Each operating system has an API programming languages can request multi-threading to use in a program. The implementation is platform dependent. C++ (now) has the std::thread that has operating system dependent calls. Java has classes that implement calls from the virtual machine to the operating system for requesting a thread.

I assume that the gains for some languages using multi-threading may be negligible

No, the gains from using multi-threading in general may be negligible depending on the application requirements. I would say it's more important how an application uses threading to accomplish a task than worry about the overhead each language has to access multi-threading.

PDizzle745
  • 356
  • 1
  • 7
0

I think most modern languages do multitasking well. Modern being c++11 ,java, c#, d etc.

However most programs don't benefit from multitasking not because of the language in use, but because the algorithm being multi threaded Doesn't benefit from parallel processing. Think sorting algorithm and the like.

Colin Grogan
  • 2,462
  • 3
  • 12
  • 12
  • sorting can be nicely multi-threaded, split into n parts, sort each part, merge – pm100 Jan 30 '15 at 21:35
  • So it's like what PDizzle said: it's not about the language/platform but rather how well it is implemented in the coding and whether or not it meets the needs of the application? – Kamikaze Rusher Jan 30 '15 at 22:35