This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Groovy and the fly likes Concurrency in Groovy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Concurrency in Groovy" Watch "Concurrency in Groovy" New topic

Concurrency in Groovy

charu shila

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

Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

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

A good workman is known by his tools.
Matthew Taylor

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
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Concurrency in Groovy
It's not a secret anymore!