This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Concurrency in Groovy

 
charu shila
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Could somebody please tell me how to handle concurrency issues in Groovy?


regads
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At this point, it's exactly like you would handle concurrency in Java.
 
Matthew Taylor
Rancher
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic