Are there any Java-specific techniques (things which wouldnt apply to C++) for writing low latency code, in Java? I often see Java low latency roles and they ask for experience writing low latency Java- which sometimes seems a little bit of an oxymoron.The only think I could think of is experience with JNI, outsourcing I/O calls to native code. Also possibly using the disruptor pattern, but thats not an actual technology.Are there any Java specific tips for writing low latency code?I am aware there is a Real Time Java Spec, but I have been warned real-time is not the same as low latency.... 
Writing low latency Java
java;performance;caching;latency
In addition to Martijn's comments I'd add:Warm up your JVM.  Bytecode starts starts off being interpreted for Hotspot andthen gets compiled on the server after 10K observations. Tiered Compilation can be a good stop gap.Classloading is a sequential process that involves IO to disk.  Makesure all the classes for your main transaction flows are loadedupfront and that they never get evicted from the perm generation.Follow the Single Writer Principle to avoid contention andthe queueing effect implications of Little's Law, plus studyAmdhal's Law for what can be parallel and is it worth it.Model you business domain and ensure all your algorithms are O(1) orat least O(log n).  This is probably the biggest cause ofperformance issues in my experience.  Make sure you have performancetests to cover the main cases.Low-latency in Java is not just limited to Java.  You need tounderstand the whole stack your code is executing on.  This willinvolve OS tuning, selecting appropriate hardware, tuning systemssoftware and device drivers for that hardware.Be realistic. If you need low-latency don't run on a hypervisor.  Ensure you have sufficient cores for all threads that need to be in the runnable state.Cache misses are your biggest cost to performance.  Use algorithmsthat are cache friendly and set affinity to processor cores eitherwith taskset or numactl for a JVM or JNI for individual threads.Consider an alternative JVM like Zing from Azul with a pause-lessgarbage collector.Most importantly get someone involved with experience.  This willsave you so much time in the long run.  Shameless plug :-)Real-time and low-latency are distinctly separate subjects although often related.  Real-time is about being more predictable than fast.  In my experience the real-time JVMs, even the soft real-time ones, are slower than the normal JVMs.