News for hackers. Stuff that matters.
Re:Don't Share Java FileChannels by yjftsjthsd-h on Sunday March 12, 2023 @06:04PM (#35126903)
I mean, unironically if you can[0] that's probably not a bad approach - just document (or programmatically ensure) that your code isn't multi thread safe and call it a day.

[0] A major caveat, but often true for "boring" business logic applications.

Re:Don't Share Java FileChannels by mcapodici on Sunday March 12, 2023 @06:12PM (#35126981)
I have done barely any multithreaded coding, but if I had to I would look at akka etc. first; i.e. use a framework!
Re:Don't Share Java FileChannels by marginalia_nu on Sunday March 12, 2023 @06:16PM (#35127009)
Java's actually got pretty sane multithreading support. Some classes are doing things that are a bit unintuitive (like this one), but once you grok the Java Memory Model it's actually very straightforward.
Re:Don't Share Java FileChannels by exabrial on Sunday March 12, 2023 @09:16PM (#35129312)
I agree with this. Memory safety, plus concurrency built into the memory model, and very well documented API pretty much make it a breeze.
Re:Don't Share Java FileChannels by yjftsjthsd-h on Sunday March 12, 2023 @06:16PM (#35127011)
Oh sure - there are lots of great tools to do it these days. My point is mostly that in most cases you can just skip it all together.
Re:Don't Share Java FileChannels by midoBB on Monday March 13, 2023 @02:48PM (#35140497)
Akka is the only way I could be sure that my concurrent code would most likely not make everything on fire. Especially Typed Akka.