View Single Post
  #2   Spotlight this post!  
Unread 19-02-2010, 18:35
timothyb89 timothyb89 is offline
code monkey
FRC #1977 (Loveland High Robotics)
Team Role: Alumni
 
Join Date: Oct 2008
Rookie Year: 2009
Location: Loveland, Colorado
Posts: 45
timothyb89 will become famous soon enough
Re: Multi-threading issue?

How are you actually running the thread code? From the looks of things, your code could be simply calling the run() method and not Thread.start()- doing that would prevent a new thread from starting and the camera code would just run in the same thread as everything else, causing the problems you're describing.

Instead of
Code:
public class CameraThread extends Thread {
    ...
}
try using:

Code:
public class CameraThread implements Runnable {
    ...
}
and then start the thread with (either in CameraThread's constructor or wherever you make an instance of it):
Code:
new Thread(someCameraThreadInstance).start();
Hopefully that could clear up some issues- although there's technically nothing wrong with just extending Thread, it can lead to some issues down the line that aren't generally a problem when just using Runnable.

If you need some examples, we've done something a lot like what you're trying to do with our code: Camera controller and thread starting code (line 64).
Reply With Quote