<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Java on Lloyd Rochester's Geek Blog</title><link>https://lloydroc.github.io/categories/java/</link><description>Recent content in Java on Lloyd Rochester's Geek Blog</description><generator>Hugo</generator><language>en</language><copyright>Copyright © 2025, Lloyd Rochester.</copyright><lastBuildDate>Thu, 30 Jan 2020 10:53:31 +0000</lastBuildDate><atom:link href="https://lloydroc.github.io/categories/java/index.xml" rel="self" type="application/rss+xml"/><item><title>User Name Search with Apache Lucene</title><link>https://lloydroc.github.io/post/java/lucene_lower_case_whitespace_analyzer/</link><pubDate>Thu, 30 Jan 2020 10:53:31 +0000</pubDate><guid>https://lloydroc.github.io/post/java/lucene_lower_case_whitespace_analyzer/</guid><description>&lt;h1 id="hahahugoshortcode77s0hbhb">User Name Search with Apache Lucene&lt;/h1>
&lt;p>I wanted to use Apache Lucene to search User Names. It&amp;rsquo;s definitely not straightforward. This post explains how to do it by defining our own custom &lt;code>Analyzer&lt;/code> and explaining how we form the &lt;code>Document&lt;/code>, index the user names and query with a &lt;code>PrefixQuery&lt;/code>.&lt;/p>
&lt;p>First of all if you&amp;rsquo;re using Apache Lucene you&amp;rsquo;re my type of person! It&amp;rsquo;s an awesome project, but the documentation and examples are severely lacking.&lt;/p></description></item><item><title>Java Cyclic Barrier</title><link>https://lloydroc.github.io/post/java/cyclic-barrier/</link><pubDate>Mon, 25 Feb 2019 08:00:00 +0000</pubDate><guid>https://lloydroc.github.io/post/java/cyclic-barrier/</guid><description>&lt;h1 id="hahahugoshortcode76s0hbhb">Java Cyclic Barrier&lt;/h1>
&lt;p>Imagine a scenario where you have N threads and can only do something when M of them are ready. Java already has this built in since 1.5 with the &lt;a href="https://docs.oracle.com/javase/10/docs/api/java/util/concurrent/CyclicBarrier.html#await(long,java.util.concurrent.TimeUnit)">CyclicBarrier&lt;/a>.&lt;/p>
&lt;p>From the Javadoc we see the CyclicBarrier is &lt;em>A synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point. CyclicBarriers are useful in programs involving a fixed sized party of threads that must occasionally wait for each other. The barrier is called cyclic because it can be re-used after the waiting threads are released.&lt;/em>&lt;/p></description></item><item><title>Java Multicore Example</title><link>https://lloydroc.github.io/post/java/multicore/</link><pubDate>Sun, 24 Feb 2019 14:57:00 +0000</pubDate><guid>https://lloydroc.github.io/post/java/multicore/</guid><description>&lt;h1 id="hahahugoshortcode75s0hbhb">Java Multicore Example&lt;/h1>
&lt;p>Any program these days that does any significant computational load should utilize the available processor cores. In this post we&amp;rsquo;ll show an example using Java where we schedule &lt;a href="https://docs.oracle.com/javase/10/docs/api/java/util/concurrent/Callable.html">Callables&lt;/a> on all available processor cores. In Java a Callable is task that returns a result and may throw an exception. It is very similar to a &lt;a href="https://docs.oracle.com/javase/10/docs/api/java/lang/Thread.html">Thread&lt;/a>, but gives a much easier way to return the result asynchronous computation. I typically don&amp;rsquo;t see many reasons to not use Callables over Threads, since even if you don&amp;rsquo;t want or need to return the result you can still return some sort of status code. This blurb is directly from the Javadoc &lt;em>The Callable interface is similar to Runnable, in that both are designed for classes whose instances are potentially executed by another thread. A Runnable, however, does not return a result and cannot throw a checked exception.&lt;/em>&lt;/p></description></item></channel></rss>