tsudot
tsudot

Reputation: 543

Threading in application programming

Why is it that the C threading library (pthreads) not as popular as the java one when it comes to application development?

Is it just the memory management issue or are there other major advantages involved?

Upvotes: 0

Views: 218

Answers (8)

Shibin k.reeny
Shibin k.reeny

Reputation: 31

Java is mainly application programming language so more people and companies are on to it, whereas c is more of a system level programming and core programming which is less popular compared to application programming.

Upvotes: 0

Clifford
Clifford

Reputation: 93476

Surely this is a question about the popularity of Java vs C rather than one library over the other. I imagine most developers select the development language not the threading library. Once the language is selected this constrains the library choice; after all you cannot use pthreads in Java.

Another point is that in C there is no standard threading library, although pthreads is commonly available on many platforms.

I also doubt the premise; if we assume that you really mean that Java is more popular than C (since that is perhaps the implication), then I doubt it is true generally. In certain application domains maybe, but it is not an easy thing to measure. Depending on how you measure it, you can make Java, C, C++, PHP, JavaScript, Python, and even D look like the world's most popular programming language.

It is possible I suppose that if you choose to use multi-threading, this may lead to a decision to prefer Java (though I doubt that too), but that is a different decision process than choosing pthreads over Java threads.

Upvotes: 0

Magnus Hoff
Magnus Hoff

Reputation: 22089

I'd say threading is too popular in Java, for example because it is hard to do asynchronous I/O. It looks to me like libraries in Java are designed with the attitude that threads are good. Library designers using C simply have the opposite attitude :)

Upvotes: 1

crowne
crowne

Reputation: 8534

The Qt framework offers a platform independent implementation for threads in C++.
It has borrowed extensively from java and is a lot newer than some the libraries mentioned earlier so its still gaining in popularity.

Upvotes: 0

In addition to the matter of (non-)portability mentioned by others, systems that implement pthreads often also implement cheap and easy multi-process programming, and that was how parallel unix programs were written for a very long time.

Upvotes: 1

Yann Ramin
Yann Ramin

Reputation: 33177

pthreads are not implemented natively on all OSes, such as Windows (there is a Win32 API for that). In fact, C as a language has no concept of threads.

Java was built with threads integrated into the language. C was not.

Upvotes: 7

Jerry Coffin
Jerry Coffin

Reputation: 490108

It's not entirely portable -- pthreads is parts of POSIX, and not normally provided under (for one obvious example) Windows.

C++ 0x adds threading primitives to the standard library (and they're mostly quite similar to pthreads) which is what most new code is likely to start using fairly soon (and some already does).

pthreads are also fairly low-level and kind of a pain to use well; many application programs will probably be better off using futures (roughly similar to the Java objects of the same name) for many of the relatively simple threading situations.

Upvotes: 4

aioobe
aioobe

Reputation: 420951

It depends completely on which type of application you have in mind writing. Perhaps the applications you're referring to are more convenient to write in a high level language such as Java.

Upvotes: 2

Related Questions