6 ms·
.net has had this feature for a decade++
by kjto 3y ago
.net has had this feature for a decade++
- spuz 3y agoWhat is the virtual thread feature in .NET called? I can't find any information about it.
- kjto 3y agoTasks, simple intro here https://code-maze.com/csharp-tasks-vs-threads/ https://code-maze.com/csharp-tasks-vs-threads/
- spuz 3y agoThat looks similar to Java FutureTasks + Executors which is a very different concept from virtual threads. Virtual threads mean that a blocking thread can yield to any other non blocking thread seamlessly and with very little overhead. .NET Tasks cannot do this as far as I can tell.
- gpderetta 3y agoI don't think this is the same thing. As far as I can tell, the task abstraction is a threapool where you can submit operations and return futures. If a task blocks indefinitely, the underlying threadpool OS worker thread will be blocked, and the threadpool either has to run with less resources or spawn a new worker. Virtual threads are an M:N abstraction: blocking on a virtual thread will not block the underlying OS thread. .NET might indeed have a virtual thread abstraction and if it does you could of course implement the Task abstraction on top of either virtual threads or OS threads, but what you linked to is not a proof that it does.
- marginalia_nu 3y agoYeah, so has a lot of languages. See the previous comment.
- kjto 3y agoyou’re trying to support “judicious and conservative” but realistically java is on a lifeline like fortran, delphi and objectiveC
- marginalia_nu 3y agoWhat are you basing this sentiment on?
- kaba0 3y agoThat “lifeline” is apparently the same the internet is on.
- foota 3y agoAre you sure? All the discussion I can find online makes it seem to me like TPL and friends are just executing tasks on thread pools until completion. (see e.g., https://github.com/dotnet/runtime/issues/50796 https://github.com/dotnet/runtime/issues/50796 for some discussion)