|Posted by Unknown W. Brackets|
in reply to Someone
Posted in reply to Someone
Depends on what you mean by inherently.
Do you mean "naturally", as in... "does D use multithreading even if my code never has anything to do with threads in it?" If you do, the answer is no. D does not automatically make a program threaded.
On the other hand, you may be asking, "can I write multithreaded programs with D, and does it make it easy?" If this is your question, than the answer is yes.
For more information, I suggest you look here:
It really is fairly trivial to write a threaded network daemon in D. Behind the scenes, it either uses CreateThread() and friends or POSIX Threads (pthread.) However, using std.thread ensures that the garbage collector and your threads are properly introduced.
For concurrency, the language provides for basic locking. For that, see here:
You can use synchronize for execution of just a statement or group thereof, or lock based on an object for multiple code blocks. As far as I know, it again just uses EnterCriticalSection()/etc. or POSIX Threads.
This isn't always as much as people want, and for more there is at least one port of a concurrency library in progress - probably others.
Incidentally, you can search using Google. Just try "site:digitalmars.com something to search for".
> Sorry if this has been asked before. I didn't know how to search (:noob).
> Does D support multithreading inherently? What is the concurrency mechanism
> I tried to look in the language comparison page, but couldn't find any info
> about this.
> Thanks you very much in advance.