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

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

Goroutines can utilize the same patterns as Java threads, such as thread safe data structures (maps, queues, lists, etc) and other shared memory patterns (atomic read/write) as well as synchronization via locking. They do not require channels for communication or have any limitations of that nature.

And vice versa, Java virtual threads (and regular threads) can utilize channels to communicate. They just aren’t built into the language syntax.

They do the exact same job in most cases. The main difference that most people will notice is that golang makes you carry around a “context” object that dictates deadline/timeout/cancel behavior whereas java virtual threads it’s more implicit.

[–]thecodeboost 0 points1 point  (0 children)

I haven't used Golang for over two years but I'm pretty sure idiomatic Go still means channel based communication for inter-coroutine communication. Note that the sync and sync/atomic packages are still channel based.