Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Jan Burse Newsgroups: comp.lang.java.programmer Subject: Channel Switch in GO, can I do this with java.nio Date: Mon, 17 Oct 2011 19:02:36 +0200 Organization: albasani.net Lines: 27 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net 5uAIGYaQ9i35RSX2kRy4gTPCntctrZfk3rwPl0HSjPmi6K1Y6DHZkv3j39mFCFauHb88tvgPt3KlRW4vbTmM+fFyL/7lKiyDfhhPSfcPva3YfUwrxfst6dMhDOSCeUlq NNTP-Posting-Date: Mon, 17 Oct 2011 17:02:37 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="U/e52ZdMQYzBJxgk1QPe6hsv8Vhlr+lHpu/42LFA0KpHYtySHd9y3LdIJ6VmByazlVxz/C2V/8zRzqduDz3TlxKerxYr0z/wcx6yIS2afKirydrLBEAIbEKZ3VdBgJin"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20110928 Firefox/7.0.1 SeaMonkey/2.4.1 Cancel-Lock: sha1:hlUOAt0Nbe8iD6ABS7H0h06Bh0E= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8925 Dear All, I am just wondering whether a Go programming language construct can be done in Java by means of some standard packages. The Go programming language construct, is the switch statement over channels: switch { c <- channel1: /* do something 1 */ c <- channel2: /* do something 2 */ } I interpret this that the code will try to fetch data from channel1 and channel2, and depending on which channel has fist some data, the corresponding code will be executed? How could this be done in Java? I have the feeling that read() does not work since it blocks, and that available() would not work since it would involve polling. So something else could solve the problem... Best Regards