View Single Post
  #2   Spotlight this post!  
Unread 07-02-2010, 16:25
SavtaKenneth SavtaKenneth is offline
Registered User
AKA: Yotam Kenneth
FRC #2212
Team Role: Alumni
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Israel
Posts: 63
SavtaKenneth will become famous soon enough
Re: Multithreading with Java? Anyone using it?

We are doing a multithreaded application. I'm at home right now so I don't have any hand on code examples but for how to program using threads in java look into Thread class and the Runnable interface. Basically a threaded camera/targer would look something like this

Code:
public class Targeter implements Runnable{
Arguments
Arguments
Arguments
Arguments

public void run(){
while(true){
     aimTheTarger();
}

public void start(){
Thread p = new Thread(this,"This is a Thread");
p.start();
}

public class Vision implements Runnable{
Arguments
Arguments
Arguments
Arguments

public void run(){
while(true){
     TakeAPicture();
}

public void start(){
Thread p = new Thread(this,"This is a Thread");
p.start();
}

Also look into the synchronized keyword which is useful for making sure threads don't interrupt each other.
Good luck

~Kenneth
Team #2212 The Spikes
Reply With Quote