KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have asked a related question before Why OCaml's threading is considered as `not enough`? No matter how "bad" ocaml's threading is, I notice some libraries say they can do real threading. For example, Lwt Lwt offers a new alternative. It provides very light-weight cooperative threads; ``launching'' a thread is a very fast operation, it does not require a new stack, a new process, or anything else. Moreover context switches are very fast. In fact, it is so easy that we will launch a thread for every system call. And composing cooperative threads will allow us to write highly asynchronous programs. Also Jane Street 's aync_core also provides similar things, if I am right. But I am quite confused. Do Lwt or aync_core provide threading like Java threading ? If I use them, can I utilise multiple cpu? In what way, can I get a "real threading" (just like in Java) in OCaml? Edit I am still confused. Let me add a scenario: I have a server ( 16 cpu cores ) and a server application. What the server application does are: It listens to requests For each request, it starts a computational task (let's say costs 2 minutes to finish) When each task finishes, the task will either return the result back to the main or just send the result back to client directly In Java, it is very easy. I create a thread pool, then for each request, I create a thread in that pool. that thread will run the computational task. This is mature in Java and it can utilize the 16 cpu cores. Am I right? So my question is: can I do the same thing in OCam
Tags (comma-separated)
Save Edits
Cancel