You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by gi...@apache.org on 2023/04/14 23:01:32 UTC

[groovy-dev-site] branch asf-site updated: 2023/04/14 23:01:29: Generated dev website from groovy-website@ffa2876

This is an automated email from the ASF dual-hosted git repository.

git-site-role pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/groovy-dev-site.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new 64fd882  2023/04/14 23:01:29: Generated dev website from groovy-website@ffa2876
64fd882 is described below

commit 64fd8824c77ccb4ee75868773ff1443845b3f425
Author: jenkins <bu...@apache.org>
AuthorDate: Fri Apr 14 23:01:29 2023 +0000

    2023/04/14 23:01:29: Generated dev website from groovy-website@ffa2876
---
 blog/gpars-meets-virtual-threads.html | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/blog/gpars-meets-virtual-threads.html b/blog/gpars-meets-virtual-threads.html
index 1898af4..0a51553 100644
--- a/blog/gpars-meets-virtual-threads.html
+++ b/blog/gpars-meets-virtual-threads.html
@@ -130,7 +130,25 @@ threads for such code easy:</p>
 <p>Nice! Using virtual threads is very simple!</p>
 </div>
 <div class="paragraph">
-<p>Let&#8217;s move onto some examples which might be
+<p>Let&#8217;s look at one more example, the <a href="https://en.wikipedia.org/wiki/Fizz_buzz">FizzBuzz</a> example:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code data-lang="groovy">var result = withExistingPool(Executors.newVirtualThreadPerTaskExecutor()) {
+    (1..15).collectParallel {
+        switch(it) {
+            case { it % 15 == 0 } -&gt; 'FizzBuzz'
+            case { it % 5 == 0 } -&gt; 'Buzz'
+            case { it % 3 == 0 } -&gt; 'Fizz'
+            default -&gt; it
+        }
+    }.join(',')
+}
+assert result == '1,2,Fizz,4,Buzz,Fizz,7,8,Fizz,Buzz,11,Fizz,13,14,FizzBuzz'</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Now, let&#8217;s move onto some examples which might be
 less familiar to Java developers.</p>
 </div>
 <div class="paragraph">