Skip to content

Instantly share code, notes, and snippets.

class Santa {
volatile int reindeers = 0;
// Call this in any old thread when a reindeer arrives
public synchronized void reindeerArrived() {
reindeers++;
notify();
}
// Returns only when 8 or more reindeer have come in
$ time scanimage -d net:localhost:pixma --resolution 600 > /tmp/blah
real 1m47.591s
user 0m0.015s
sys 0m0.159s
Equivalent Java test:
SaneDevice device = session.getDevice("pixma");
device.open();
device.getOption("resolution").setIntegerValue(600);
Stopwatch stopwatch = Stopwatch.createStarted();