Go to Post "Splet" is the sound a frog makes when it hits pavement at 187 feet per second. Don't ask me how I know. - dlavery [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 09-02-2016, 16:15
seg9585's Avatar
seg9585 seg9585 is offline
Registered User
AKA: Eric
FRC #4276 (Surf City Vikings)
Team Role: Engineer
 
Join Date: Feb 2006
Rookie Year: 2001
Location: Boeing (Seal Beach, CA)
Posts: 520
seg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond repute
Java Threading Question

Question to those of you who use Threading (class MyClass extends Thread implements Runnable) for various scripting:

We wrote a Thread class that carries out a script upon button press (in our case, performing about 5 mechanical timed functions in sequence to shoot our boulder). The script itself is in our void run(){} method and gets invoked upon callout of our shooterclass.start();
The script in run() is not an infinite loop -- it would merely end and I would *think* the thread itself would terminate.

So, when the script is complete and sometime in the future I press the same button, calling out MyClass.start(); a second time throws an exception. The only way I've gotten around this was to generate a new Thread (shooterclass = new MyClass(); ) before calling out shooterclass.start(); again.
Even though this works, I'm worried I'm just creating a ton of new threads that will bog down the roboRio eventually. What is the correct way to terminate a Thread? the API says Thread.stop() is deprecated
Should I just assume the thread is always running, allowing me to specifically call out shooterclass.run() in the 2nd iteration and beyond?
__________________
My FIRST legacy:

Team 204 Student 2001, 2002 (Voorhees, NJ)
Team 1493 College Mentor 2006 - 2008 (Troy, NY)
Team 2150 Intern/Professional Mentor 2007, 2009 (Palos Verdes)
Team 4123 Lead Engineering Mentor 2012 (Bellflower, CA)
Team 4276 Engineering Mentor 2012-2016 (Huntington Beach, CA)
 


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


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

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