Go to Post People don't have to "get" it. They just have to know about it. Once they know about it, then they come to it, experience it, talk to it, learn it, then get it. - Taylor [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
Team 51   CD-Events   CD-Media   CD-Swap   CD-Spy   FRC-Spy   Unsung FIRST Heroes   WFA
portal register members calendar search Today's Posts Mark Forums Read FAQ rules
VEXpro
The Chief Delphi Forums are sponsored by Innovation First International, Inc.
Delphi
ADVERTISEMENT

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-14-2010, 08:16 PM
NinJA999's Avatar
NinJA999 NinJA999 is offline
Chipmunk NinJA
AKA: Nick Aldwin
FRC #0811 (Team 811)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Windham, NH
Posts: 45
NinJA999 will become famous soon enough
Send a message via AIM to NinJA999 Send a message via Skype™ to NinJA999
Wait Exception?

We've been porting some of our code from last year into Java. We tried to execute a wait command, but first we had to wrap it in a try catch statement. It catches the exception with the message:
"current thread (first.team811.game2010.Team811Robot - main (pri=5)]) not owner (null)"

Is there a way we can utilize wait in Java?
__________________
Team 811 (Nashua, NH) - Mentor

Previously Team Lead & Programming Lead
Reply With Quote
  #2   Spotlight this post!  
Unread 01-15-2010, 07:35 AM
derekwhite's Avatar
derekwhite derekwhite is offline
Java Virtual Machine Hacker
no team (FIRST@Oracle)
Team Role: Programmer
 
Join Date: May 2009
Rookie Year: 2009
Location: Burlington, MA
Posts: 127
derekwhite is on a distinguished road
Re: Wait Exception?

You didn't post your code, but the likely problem is that in Java you need to lock your object before doing a wait() or notify() on it. The Java wait() will unlock the object, wait until it receives a notify, then relock the object.

You can find some details on this in the Java Tutorial:
http://java.sun.com/docs/books/tutor...guardmeth.html
Reply With Quote
  #3   Spotlight this post!  
Unread 01-15-2010, 10:21 AM
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 486
BradAMiller has much to be proud ofBradAMiller has much to be proud ofBradAMiller has much to be proud ofBradAMiller has much to be proud ofBradAMiller has much to be proud ofBradAMiller has much to be proud ofBradAMiller has much to be proud ofBradAMiller has much to be proud ofBradAMiller has much to be proud of
Re: Wait Exception?

Instead of using Wait() you need to use Timer.delay(). The problem with Wait is that is a method on the Object class which is the base for all objects. So using wait doesn't really work.

First, be sure you have this import:
Code:
import edu.wpi.first.wpilibj.Timer;
Then, here is an example of using delay:
Code:
    public void autonomous() {
        System.out.println("In autonomous");
        for (int i = 0; i < 40; i++) {
            drivetrain.drive(1, 0.0);
            Timer.delay(2); // wait 2 seconds
            drivetrain.drive(-1, 0); 
            Timer.delay(2);
        }
        drivetrain.drive(0.0, 0.0); // drive 0% forward, 0% turn (stop)
    }
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote
  #4   Spotlight this post!  
Unread 01-15-2010, 01:13 PM
NinJA999's Avatar
NinJA999 NinJA999 is offline
Chipmunk NinJA
AKA: Nick Aldwin
FRC #0811 (Team 811)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Windham, NH
Posts: 45
NinJA999 will become famous soon enough
Send a message via AIM to NinJA999 Send a message via Skype™ to NinJA999
Re: Wait Exception?

Great, thanks!
__________________
Team 811 (Nashua, NH) - Mentor

Previously Team Lead & Programming Lead
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
Exception in Timer.cpp Phazonmutant WindRiver C++ 2 02-17-2009 08:27 AM
Target Exception - Exception in Kernal Task Thxe WindRiver C++ 3 02-10-2009 06:24 AM
error - language-plug-in exception... RedOctober45 Programming 1 01-16-2008 02:54 PM
Joystick Exception? Blair Frank IFI Control System 3 02-09-2007 09:41 PM
Can't wait Rabid Robots OCCRA 0 11-15-2002 09:36 PM


All times are GMT -5. The time now is 03:37 AM.

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


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright © Delphi and Pontiac Central High School