Message-ID: <258662935.11820.1422655052974.JavaMail.email@example.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_11819_1889141690.1422655052973" ------=_Part_11819_1889141690.1422655052973 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Using the Groovy Fast Track you will start experimenting with GP= ars in about 3 minutes. We assume you have Groovy installed on your system.=
Start fresh Groovy Console or open up an empty groovy script source in y= our favorite IDE
Note: GPars comes bundled with Groovy distributions so this step sho= uld normally be not required.
We'll use Groovy's Grape functionaity to grab all the requited dependenc= ies for us. You may check ot the GPa= rs Integration page for alternative ways to integrate GPars with your p= roject.
Add the following line to the groovy script:
Believe it or not, now, we're ready to experiment. Try the following scr= ipt, which will concurrently query a collection of strings with regular exp= ressions:
Run the script and you should get the following output:
Now feel free to experiment changing the regular expressions, using diff= erent collections or different methods, like eachParallel(), collectParalle= l(), maxParallel(), sumParallel() and others. You get the idea, right?
Now we could try to build an actor and send it a couple of messages to s= ee it acting.
Our actor maintains a private counter and accepts different types of mes= sages, which result in updating the counter. Sending a null value will make= the actor reply the current counter value back to us. Notice the send(= ) method name is optional and can be replaced by the <<= operator or ommited altogether.
Now when you have GPars runing on your system, the time is up you opened= up the User Guide, browsed the GPars code examples and continued experimentin= g. You may also consider checking out the Java Fast Track, in case you need to use GPars high-level con= curency abstractions from Java code. Good luck!