Building low latency Java applications with Java 22 and beyond

By dave

This article discusses my opinions around moderate latency and low latency applications built on the JVM using JDK 22 and greater. It is based on many years of trying various approaches. For years the regular way to build exceptionally low latency (or more correctly low GC pause) applications was to avoid memory allocations in the critical parts of the application, and...

Does the native linker change the status-quo for JVM low latency?

By dave

This article discusses if the Java 22 foreign memory API and value classes change my view of the status quo for building applications that communicate with C++ components and the possible latencies in that approach. In the past, with JNI as the C++ go between, there were enough disadvantages that sufficiently down voted this option to the basement. Let's investigate a...

Filtered extraction from zip file using ZipInputStream and Java 8

By dave

In the example below we build on the Reading a zip file from java using ZipInputStream page to provide basic filtering. This filtering is provided by the filteredExpandZipFile method taking a Predicate. Every ZipEntry is passed to the predicate, but only ones that match (predicate returns true) are included. Note that the size of an entry cannot be accurately determined in...

Using Future and ConcurrentMap for a lazy cache

By dave

In this example I demonstrate how to use ConcurrentMap along with Future to generate a lazy cache. Concurrent maps are a good choice in some situations, where absolute atomicity can be traded off for performance, some level of control over ordering of events has been traded for performance. Let's assume for the sake of example that we have an object that...

Writing a zip file in java using ZipOutputStream.

By dave

Following on from one of our popular articles on Reading a zip file from java using ZipInputStream we've put together a new article on how to create a zip archive using Java. The below example uses ZipOutputStream to create a zip file from all the items in a directory. Zip files are written slightly differently to a normal stream in that...

Old Generation GC and cache performance?

By dave

This is a question as much as a discussion, I can’t find a lot of detail on the state of play in this area and would really welcome any feedback or corrections. Please don’t read this as a negative article as that is not how it is intended; it’s in the optimisation section but I’m not sure what impact it really...

Simple uses of CountDownLatch

By dave

CountDownLatch provides a means of waiting for a number of asynchronous events before proceeding. In order to do this one constructs a latch providing the event count. Then one thread would normally call whilst the other thread calls . Once the count reaches zero the call returns and the latch is set. If the call to happens after...

Formatting dates in Java with DateFormat

By dave

There are several ways to format dates in Java, but by far the easiest is to use DateFormat. Creating a DateFormat is very similar to NumberFormat that we saw on the previous page. Here are the static factory methods called directly on the DateFormat class: getDateInstance(..) getDateTimeInstance(..) getTimeInstance(..) There are several overloaded versions of each method above. We will not cover...

The background, string formatting in java

By dave

Over the years there have been no shortage of ways to format a string in java. What with the + operator, , , and various specialised formatters for numbers and dates we sometimes feel a little spoilt for choice. But how do they all work and what are their advantanges / disadvantages? StringBuffer - a hang up from times gone...

Using Java's XMLStreamReader PULL XML Parser

By dave

In this entry I show how to use the inbuilt Java XMLStreamReader PULL parser class to read an XML file. The XML stream libraries are PULL based XML parsers that do not load the whole document into a memory structure, so therefore are more suited to large volumes of XML. Below is an example XML file for a zoo, it contains...

These may be of interest

We use cookies to analyse traffic and to personalise content. We also embed Twitter and Youtube on some pages, these companies have their own privacy policies.

See the privacy policy and terms of use of this site should you need more information or wish to adjust your settings.