Hacker News new | past | comments | ask | show | jobs | submit login

Go suffers the same issue when calling into native code, that is why it has APIs to deal with it.

For example, https://pkg.go.dev/runtime#LockOSThread




This seems different.

It pins goroutine until it is explicitly released ensuring that multiple native calls will remain on the same platform thread and nothing else is going to use it. This is critical for namespace manipulation on Linux.

Java only pins for duration of native call and synchronized blocks.

It looks like Java does not offer equivalent API? For now could be achieved with synchronized but if synchronized will be changed in the future to not pin it would break.


Oh, actually one can just spawn non-virtual thread to solve it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: