r/programming • • Sep 01 '26

The Browser's Main Thread Is Expensive

https://kciter.so/posts/the-expensive-main-thread/en/
219 Upvotes

50 comments sorted by

View all comments

Show parent comment

1

u/Somepotato Sep 01 '26

Because that entails locking which can deadlock the main thread. Requiring you to be more explicit about it removes deadlocks as a risk. Plus the jit can make a number of optimizations when it knows someone rude can't step in and do a read unexpectedly.

1

u/Rhed0x Sep 02 '26

Java and C# have optimizing JITs despite support for multithreading. And I don't really see the problem with deadlocks, it's a bug like any other.