Difference between volatile and synchronized in Java

It’s important to understand that there are two aspects to thread safety. execution control, and memory visibility The first has to do with controlling when code executes (including the order in which instructions are executed) and whether it can execute concurrently, and the second to do with when the effects in memory of what has been done … Read more

How to implement a most-recently-used cache

Java Collections provide LinkedHashMap out of the box, which is well-suited to building caches. You probably don’t have this in Java ME, but you can grab the source code here: http://kickjava.com/src/java/util/LinkedHashMap.java.htm If you can’t just copy-paste it, looking at it should get you started implementing one for inclusion in your mobile app. The basic idea … Read more

Image rotation algorithm

One of the best pages describing image rotation algorithms I’ve found on the internet is tied to Dan Bloomberg’s excellent leptonica library. While the leptonica library itself is written in C and won’t help you, his page on image rotation algorithms: http://www.leptonica.org/rotation.html is definitely worth a read. You will most likely want to implement something … Read more