A while ago I joined a project which had some old school (naive) approaches to concurrent processing in an object oriented language.
In these enlightened times I automatically double check whenever I see a Java class that has been declared with "extends Thread" (not just because some former colleagues regarded the extends keyword as blasphemy).
I've read enough to know to prefer implementing an interface rather than extending a concrete class. In this case the appropriate Interface is Runnable, without even delving into the excellent java.util.concurrent APIs.
For this most recent project I have gradually eliminated all "extends Thread", sometimes by simply implementing Runnable, and sometimes by introducing a TimerTask.
Today I have been troubleshooting some problems which our Java application has when interacting with native code (compiled C++ libraries for interacting with hardware). As part of this exercise the application needed to be overhauled to ensure that all threads that are started are correctly shut down when Tomcat is shutdown.
jvisualvm proved to be a useful tool once again for inspecting which threads were not terminating when I ran the application on my laptop.
Like practically everything else in programming, assigning a useful name to each and every Thread and Timer made it so much easier to trace.
Remember the @PreDestroy annotation is your friend.
Stephen Souness, a Java developer recently returned to New Zealand sharing some thoughts on what's happening in the world of Cloud computing, Java and database technologies.
Wednesday, 19 October 2011
Thursday, 13 October 2011
Facebook reverse psychology on privacy
I have recently taken a few weeks off work to travel back to my home country to catch up with friends and family, and soak up some of the Rugby World Cup hype.
When it came time to look for contact details for various friends who I hadn't seen for a while, I ended up resorting to Facebook messaging.
A while ago Facebook opened some loophole which allowed me to see contact phone numbers for anyone who I was a Facebook friend with. I quickly thought of that as a not-so-good idea and opted out, but recently I have been thinking this may have been a cunning ploy by Facebook to ensure that Facebook messaging becomes the primary means of communication for situations such as mine.
One of these days I will probably leave Facebook, as it is becoming too ubiquitous so must inevitably be avoided.
Subscribe to:
Posts (Atom)