|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Multithreading with Java? Anyone using it?
Specifically, I would like to put the camera and target detection on a separate thread, but would be interested in examples of doing anything in a separate thread.
|
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
Re: Multithreading with Java? Anyone using it?
If you have a look at the GRTFramework(code.google.com/p/grtframework), you'll notice that we use multithreading extensively, with sensor and actuator abstractions/drivers being independent threads, and controllers for specific robot mechanisms acting completely independently from each other. We have not noticed any real performance costs thus far, and thus strongly recommend a threaded model to segregated robot parts.
I'm not saying that threading has no performance costs, but for the purposes of this competition they are not noticeable even with java threads. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ellipse/Shape Detection with Java | cheeser180 | Programming | 1 | 01-17-2010 10:50 AM |
| **FIRST EMAIL**/Java and Orbit Balls *****JAVA DISCUSSION*** | Pjohn1959 | Programming | 37 | 08-31-2009 03:55 PM |
| Is anyone using RoboEmu2 with the 2006/2007 controller | Mike Mahar | Programming | 4 | 08-26-2007 10:30 PM |
| Programming with Java? | the_innovator | Programming | 11 | 02-27-2007 04:47 PM |
| Learn C, C++, and Java with new board game. | Elgin Clock | Programming | 8 | 11-04-2005 01:28 PM |