Real-time control from Java

surely there is a serial read command, just check the reference here:

I think what you want is to let the Arduino read the state of whatever digital and analog inputs you need to read, then wrap the readings up in some format that your Java app. can understand. Then send the data over the serial line (The USB line is a serial line in disguise). This is quite easy. Asuming of course that your Java app. has acces to serial communication.

You can of course also go the other way, send serial info from the PC to Arduino to control the state of various output pins.

This way the Arduino board is just reading and setting input / output and the main chunk of processing is going on in the Java app.

EDIT: As for nonblocking, i dont think so. Arduino has only one thread of execution, but it is possible to use a few interrupts.

MikMo