Some sample code snippets, Java examples (example source code) Organized by topic
Read moreThread-safe state handling
As already known, you must known your synchronization strategy, ”crossing fingers and wishing nothing bad happens” or ”synchronization problems with primitive fields don’t occur” are simply not correct answers for thread synchronization. Tobe expressed: Thread-safe state handling
Read moreVisual VM: opensource java profiler
In someway interesting sound project. However, not matching tools like YourKit. visualvm: Project Home Page
Read more10 Mistakes in Icon Design
Things to keep in mind when designing icons… 10 Mistakes in Icon Design
Read moreLobo: Java Web Browser
Sounds interesting, finally possibility to embed *real* web browser capabilities into java application… Lobo: Java Web Browser
Read morePID of java process
For some reason ”getPid()” Bug Parade entry has been hanging for ever ”in progress, won’t ever fix” state. However, after quick searching there is workaround, which hopefully works in ”major” cases (meaning Linux, M$windows and OSX). NOTE: Tested logic only in Linux box. However, since logic relies into public API, it should be working in…
Read moreDid escape analysis escape from Java 6?
Short summary: Escape analysis is not enabled by default in JDK 6, and it’s available only in server JVM Thus in order to enable Escape analysis, following parameters for java are required: [code] java -server -XX:+DoEscapeAnalysis [/code] So lets run run the test from the references… Test Program [code lang=”java”] package org.kari.test; public class LockTest…
Read moreTransparent compression in RMI
If very large objects are being transferred over RMI layer, then system must do lot of work not only in serialization of the objects, but also in the transfer itself. If RMI based communication is wanted to be used across WAN environment, 100Mbit datatransfer speed is simply not available everywhere. For example, ADSL subscription lines…
Read moreSpeed up Java2D (& Swing) in Linux
Using -Dsun.java2d.opengl=true as startup argument for java when starting application using Java2D heavily (well, basically any Swing application), it improves noticeably performance in Linux environment. Currently I’m experimenting following settings in my /etc/profile.local -file. [code] _JAVA_OPTIONS=’-Xverify:none -Dsun.java2d.opengl=true’ export _JAVA_OPTIONS [/code] (_JAVA_OPTIONS is magic environment variable which is used automatically by java). I tested performance by…
Read moreProfiling Webstart applications
Profiling of the applications launched via webstart may sound difficult, but in reality it isn’t. What you need is to have approriate profiler/debugger native libraries in LD_LIBRARY_PATH of the system (or equivalent), and then specifying necessary arguments for webstart (from command line) For example, using YourKit with Webstart: [code] javaws -J-agentlib:yjpagent=tracing http://example.com/example.jnlp [/code] Same approach…
Read more