Go to Post One of the most important resources of all: [URL="http://frc-manual.usfirst.org/"]The Manual[/URL] - lorem3k [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-07-2010, 02:45 PM
adamdb adamdb is offline
Registered User
#1583
 
Join Date: Feb 2005
Location: Parker, CO
Posts: 63
adamdb has a spectacular aura aboutadamdb has a spectacular aura aboutadamdb has a spectacular aura about
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.
__________________
Adam Bryant
Programming Mentor
Team 1583
Ridge View Academy Rambotics
Reply With Quote
  #2   Spotlight this post!  
Unread 02-07-2010, 04:25 PM
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
  #3   Spotlight this post!  
Unread 02-07-2010, 11:39 PM
spartango spartango is offline
Registered User
FRC #0192 (GRT)
Team Role: Alumni
 
Join Date: Nov 2009
Rookie Year: 2008
Location: Palo Alto, CA
Posts: 43
spartango is an unknown quantity at this point
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.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


All times are GMT -5. The time now is 07:35 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi