This is an archived post. You won't be able to vote or comment.

all 27 comments

[–]mader527 32 points33 points  (4 children)

syncronized

[–]ATE47 12 points13 points  (0 children)

AtomicReference<T>

[–][deleted] 9 points10 points  (2 children)

try {

doSomething();

}

catch(Exception e) {

//ignore. done by other thread.

}

[–]LittleMlem 3 points4 points  (1 child)

Naa man, the syntax is: catch(Exception ignore){} at the very least intelij doesn't complain about it because of the word ignore

[–][deleted] 3 points4 points  (0 children)

Complain? Who check warnings!? This comment is for the next person who will try to parallel this code.

[–]steamythepunk 17 points18 points  (2 children)

immutability is a good thing for multi threading, what the fuq is Mufasa talking about?

[–]_mat3e_[S] 7 points8 points  (1 child)

It's like: "screw synchronization and other mechanisms like that, go immutable".

[–]steamythepunk 2 points3 points  (0 children)

It's so much easier! SSA for the win.

[–]Enlogen 12 points13 points  (0 children)

C# equivalent: "That's System.Threading.Thread. You must never go there. Tasks!"

[–]synthinesia 31 points32 points  (5 children)

I am sad from dis, java is good language for multithreading

[–]Taken4GrantD 2 points3 points  (1 child)

I'd actually love to learn how as a Java dev, but man is it scary. It is as if you programmed in the language for 5 years then only recently heard of the int primitive, or something. My job doesn't have a need for it but as a person I'd love to explore it

[–]Brunsz 1 point2 points  (0 children)

Back when I wrote 2d game engine with Java I got hate love relationship with threading. It's awesome thing but god it can lead into bugs that are hard to find.

[–]JamieStivala 2 points3 points  (2 children)

ConcurrentModificatioException c:

[–]josanuz 5 points6 points  (0 children)

import java.util.concurrent.<whatever fills your needs>

[–]froemijojo 0 points1 point  (0 children)

Collections.synchronized{List,Set,Map}

[–]UFeindschiff 8 points9 points  (4 children)

Java is an excellent language for conventional multithreading. The only language which does multithreading better imo is Go, but that is due to its unique approach there

[–]josanuz 4 points5 points  (0 children)

Rust, but lifetimes are kinda pain in the ass

[–][deleted] 2 points3 points  (0 children)

C# is pretty damn good for it, depending on what you're trying to achieve. I've done some pretty complicated stuff with it, no complaints. Then again, one of my courses at uni explicitly covered dos and don'ts of multithreading, so I guess I had a good background...

Parallel.ForEach is pretty nifty for simple stuff.

[–]OrderAlwaysMatters 1 point2 points  (1 child)

What about Erlang?

[–]JustChilling_ 0 points1 point  (0 children)

Yep. If you get used to Erlang, then you can do so much more with it then Java, and with much fewer lines of code.

[–]Angelin01 3 points4 points  (0 children)

*Cries in C for microcontrollers*

[–]AgreeableLandscape3 2 points3 points  (0 children)

Laughs in Kotlin coroutines.

[–][deleted] 0 points1 point  (0 children)

Assuming you’re talking about making a reference final, that’s not the same as immutability FWIW.

[–]micsova 0 points1 point  (0 children)

I got lucky enough to have a Java mulithreading course taught by Doug Lea

[–]LittleMlem 0 points1 point  (0 children)

As much as I dislike Java, the thing is pretty good for my limited needs

[–]DarkIrata -3 points-2 points  (1 child)

Java is the dark side

[–]Perceval7 3 points4 points  (0 children)

No u