Golang like channel and select for Java

712 views
Skip to first unread message

Hiroshi Sakurai

unread,
Aug 4, 2015, 1:34:00 PM8/4/15
to golang-nuts
Hi,

I've made a Java library which provides Golang-like channel and select.

It may be of interest to you if you have to use Java for work.
Any feedback is welcome.

--
Hiroshi

Micky

unread,
Aug 4, 2015, 8:35:05 PM8/4/15
to Hiroshi Sakurai, golang-nuts
If someone's looking same for C, there's Russ Cox's Libtask and Tylertreat's Chan.

https://swtch.com/libtask/
https://github.com/tylertreat/chan


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Haddock

unread,
Aug 5, 2015, 3:16:45 AM8/5/15
to golang-nuts
There is also Quasar which brings CSP to the JVM. It solves the problem that the JVM does not have green threads through the use of fibers. Nested operations on channels are also possible as it makes use of continuations. It uses this continuation implementation.

There is a little layer on top of it named Wilco.kt which adds some abstractions so that things look almost the same as in Go. Wilco.kt is written in Kotlin (but Kotlin is also a JVM language like Java).

Here is the equivalent of the pipeline sample from the Go blog. If you look at the subclasses og GoTest you see more Kotlin test cases where classic Go concurrency solutions are solved the same way in Quasar/Wilco.kt.

Note that continuations in Quasar rely on byte code manipulation (as all continuations libraries for the JVM). So when you run the samples you need set this VM option: -javaagent:${PathToQuasarCore.jar}. Otherwise things won't work.

-- Haddock

parais...@gmail.com

unread,
Aug 5, 2015, 8:00:47 AM8/5/15
to golang-nuts
While it is great, channels without Go routines ... it's much much less useful. How would you use this, inside java threads ?

Russel Winder

unread,
Aug 5, 2015, 12:03:55 PM8/5/15
to golan...@googlegroups.com
On Wed, 2015-08-05 at 05:00 -0700, parais...@gmail.com wrote:
> While it is great, channels without Go routines ... it's much much
> less
> useful. How would you use this, inside java threads ?

The various frameworks (e,g., Quasar, GPars, Akka, etc.) all use thread
pools: programmers do not program directly with threads.

--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel...@ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: rus...@winder.org.uk
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
signature.asc
Reply all
Reply to author
Forward
0 new messages