Thread library is deprecated

Hi,

I read from Chapter 30 of the manual, The threads library,

Warning: the threads library is deprecated since version 4.08.0 of OCaml. Please switch to system threads, which have the same API.

Can someone explain what it means exactly?

  • “switch to system threads”. I thought system threads were part of the Thread library
  • “same API”. Same as what?

Sorry if this sounds obvious

1 Like

Historically, OCaml has been providing two ways to write threaded program:

  • via plain system threads, which is what most people have been using
  • via an alternative implementation of Pervasives, Unix, Threads, Condition, … where all threads where running on the same system thread and IOs where multiplexed using a select loop. This is similar to what libraries such as Lwt or Async do, except without the monad

The second way was known under the name “vmthreads”. It wasn’t very well known anymore and wasn’t used very much. Additionally, it was a lot of work to maintain. Indeed, it required to maintain a parallel implementation of many modules. So we decided to deprecate it.

In practice, the majority of users can ignore this. In particular, people who didn’t know about vmthreads can safely ignore this. The Thread library using system thread is still present and maintained.

4 Likes

I think it’s still worth opening an issue or PR a documentation clarification. It’s not the threads library that is deprecated it’s the vmthread implementation that is.

4 Likes

thanks for the clarification!
I agree with @dbuenzli that the sentence in the manual could be clarified. I first thought I had to completely reorganize my program…