JProfiler
Get rid of your performance problems and memory leaks!
[Logo] JavaRanch » JavaRanch Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Win a copy of JBoss AS 5 Development this week in the JBoss forum
or Spring Dynamic Modules in Action in the Spring forum!
Reply Bookmark it! Watch this topic JavaRanch » Forums » Other Languages » Groovy
 
RSS feed
 
New topic
Author

Concurrency in Groovy

bond james
Greenhorn

Joined: Nov 24, 2001
Messages: 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
Messages: 4671

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
Messages: 108

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
 
 
 
Reply Bookmark it! Watch this topic JavaRanch » Forums » Other Languages » Groovy
 
RSS feed
 
New topic
The most intelligent Java IDE