File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Groovy and the fly likes Concurrency in Groovy Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Other Languages » Groovy
Reply Bookmark "Concurrency in Groovy" Watch "Concurrency in Groovy" New topic
Author

Concurrency in Groovy

charu shila
Greenhorn

Joined: Nov 24, 2001
Posts: 10
Hi All,
Could somebody please tell me how to handle concurrency issues in Groovy?


regads
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4695

At this point, it's exactly like you would handle concurrency in Java.


A good workman is known by his tools.
Matthew Taylor
Rancher

Joined: Jun 13, 2004
Posts: 110
The best thing about Groovy concurrency is that Closure implements Runnable. So you can very easily kick off a process running in a new thread:



You should see the parallel printouts, something like this:

Thread[Thread-15,6,main]: 1
Thread[Thread-16,6,main]: 1
Thread[Thread-15,6,main]: 2
Thread[Thread-16,6,main]: 2
Thread[Thread-15,6,main]: 3
Thread[Thread-16,6,main]: 3
Thread[Thread-15,6,main]: 4
Thread[Thread-16,6,main]: 4
Thread[Thread-15,6,main]: 5
Thread[Thread-16,6,main]: 5

[ September 05, 2008: Message edited by: Matthew Taylor ]

Grails Consultant
http://dangertree.net
 
 
subject: Concurrency in Groovy
 
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture