Something like this might work for you:
Code:
// Create a new Timer to schedule vision processing
Timer visionScheduler = new Timer("Vision Scheduler", true);
void doVisionProcessing() {
// Your vision code here
}
public void autonomousInit() {
...
// Perform vision processing every 50ms, starting in 0ms (i.e. now)
visionScheduler.scheduleAtFixedRate(new TimerTask() {
public void run() {
doVisionProcessing();
}
}, 0, 50);
}
Keep in mind that you'll need to do the normal threading stuff like locks/synchronization blocks and declaring shared variables volatile, but that applies for any multithreaded program.