Monday, April 30, 2007

How to code an inline Java Thread

This is an example for how to create an inline Java thread and launch it. The Thread Javadoc describes it in pieces and this is a complete example.

import java.util.Date;

public class InlineThreadDemo {

public static void main(String[] args) {
System.out.println(
"parent thread " + new Date(System.currentTimeMillis()));
// launch child thread using inline declaration
new Thread(
new Runnable() {
public void run() {
try {
Thread.sleep(10 * 1000);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(
"child thread " + new Date(System.currentTimeMillis()));
}
}).start();
System.out.println(
"parent thread " + new Date(System.currentTimeMillis()));
}
}

The output from the program will be someting like this.

parent thread Mon Apr 30 22:14:02 ADT 2007
parent thread Mon Apr 30 22:14:02 ADT 2007
child thread Mon Apr 30 22:14:12 ADT 2007

Wednesday, April 04, 2007

Dial tone, kleenex, Google

I got talking a little while ago with a smart guy at work. He's a veteran developer, doing it longer than I have. We have some similar views about how software should be built.

Anyway we got talking about software quality and reliability, a favorite subject. Of course when the subject is reliability the discussion immediately goes to dial tone. That was kind of interesting, we don't talk about dial tone in terms of reliability. We talk about reliability in terms of dial tone. So dial tone ends up defining reliability instead of the other way around.

It can be pretty good when you have so much mind share that the product ends up defining the term instead of the other way around. For example a guy's girlfriend could ask him to pick up some Puffs Kleenex at the drug store when he's there. That request makes good sense because everyone uses the term Kleenex to describe facial tissue. If someone says to "Google" on something, they of course mean to look it up on the Internet using a search engine.

Usually when creating software or some other product you want to achieve that kind of dial tone, kleenex, Google status. You want to have so much mind share that people define the term using the product instead of the other way around.

However there can be a downside to this if the association is a negative one. For example if someone says something is a "1.0" thing, what they mean is the historic negative experience with the version 1 release of software. That is full of bugs, slow, underfeatured, hard to use. It may not even be called version 1.0, but someone can call it that and then you're in trouble.

Another example would be calling something a "WordPerfect 6.0 for Windows". WP 6.0 for Windows is the definition of the horrible product release. Delivered late, it was extremely unstable, crashing constantly, losing data and frustrating users. That product release was a blow from which WordPerfect never recovered.

Interestingly I know a fellow who was a WP fan. He of course agreed that 6.0 for Windows was bad. However he said 6.1 was much more stable, and by 6.2 they had a good solid product. Unfortunately for WordPerfect, by the time 6.2 was out they had lost virtually all of their market share to Microsoft Word, so 6.2 was pretty much irrelevant. I wonder how many people out there know that 6.2 is pretty good, compared to those who know that 6.0 wasn't. Probably not too many. After 6.0, most people like me just tuned out WordPerfect.

So when someone calls something a "WP 6 for Windows" then you know that it's a bug filled disaster, even if the product has nothing at all to do with word processing.