Re:Java at 30: The Genius Behind the Code That Changed Tech
by PaulDavisThe1st on Friday May 16, 2025 @05:30PM
(#44009956)
The only replacement for locks/mutexes is a lock free data structure. Locks are not what make concurrency possible, they are what makes it data-safe.
You can use platform threads, user-space threads, language-provided "green" threads, goroutines, continuations or whatever you wish for concurrency management, but that's almost orthogonal to data safety.
Re:Java at 30: The Genius Behind the Code That Changed Tech
by MaxBarraclough on Saturday May 17, 2025 @04:41AM
(#44012944)
I'm not sure what you mean here, as far as I'm aware data safety isn't standard terminology.
Re:Java at 30: The Genius Behind the Code That Changed Tech
by lazide on Saturday May 17, 2025 @07:56AM
(#44013655)
I think they’re using it in the context of what you’ll get without some degree of locking, which is data corruption and/or other issues.
It’s not that you need locking to use threads. You need locking to stop threads from ruining any shared resource/data they are both trying to touch at the same time.
Re:Java at 30: The Genius Behind the Code That Changed Tech
by paulddraper on Friday May 16, 2025 @04:50PM
(#44009714)
The x86 instruction set is available as well.
Re:Java at 30: The Genius Behind the Code That Changed Tech
by saagarjha on Saturday May 17, 2025 @02:30AM
(#44012415)
Actors are implemented using locks.
Re:Java at 30: The Genius Behind the Code That Changed Tech
by pimeys on Saturday May 17, 2025 @04:45AM
(#44012956)
Is it really so? I haven't checked all the implementations, but my take here would be to use a channel with atomics instead of a lock...
Re:Java at 30: The Genius Behind the Code That Changed Tech
by saagarjha on Saturday May 17, 2025 @05:15AM
(#44013079)
It's probably possible to do if you think about it carefully but generally enqueuing a message is going to take a lock, especially if you can send an arbitrary number of messages (which may require the queue to be reallocated).
Re:Java at 30: The Genius Behind the Code That Changed Tech
by pimeys on Saturday May 17, 2025 @07:13AM
(#44013463)
One very common queue implementation you can use to implement actors is the crossbeam-deque. It's work-stealing in nature, works in multi-threaded environments and has no locks. The implementation is quite simple to follow:
https://github.com/crossbeam-rs/crossbeam/blob/master/crossb...
Re:Java at 30: The Genius Behind the Code That Changed Tech
by surajrmal on Saturday May 17, 2025 @11:25AM
(#44014986)
Note that the mpsc queue in the rust stdlib is also a clone of crossbeam and therefore also lockless.
Re:Java at 30: The Genius Behind the Code That Changed Tech
by saagarjha on Sunday May 18, 2025 @04:59AM
(#44019974)
Oh, interesting. Ok I take back my claim then.
Re:Java at 30: The Genius Behind the Code That Changed Tech
by yubblegum on Sunday May 18, 2025 @11:00AM
(#44021874)
> One very common queue implementation you can use to implement actors is the crossbeam-deque
I can't find any references to a "crossbeam dequeue" outside of Rust sources. Is this a neologism for a "very common" pattern, or just very common in Rust?
Re:Java at 30: The Genius Behind the Code That Changed Tech
by steveklabnik on Sunday May 18, 2025 @12:26PM
(#44022476)
crossbeam is a package name. It would be like googling “Nokogiri XML” and only getting Ruby results.
The generic name is just Deque. https://en.wikipedia.org/wiki/Double-ended_queue
The patterns are available, its up to the community to apply proper concurrency patterns.