Go to Post There should be no teams yelling "robot". - RoboMom [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

 
 
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 01-26-2011, 09:01 PM
flameout flameout is offline
AKA Ryan Van Why
FRC #0957 (SWARM)
Team Role: Alumni
 
Join Date: Sep 2009
Rookie Year: 2009
Location: Oregon
Posts: 168
flameout is a name known to allflameout is a name known to allflameout is a name known to allflameout is a name known to allflameout is a name known to allflameout is a name known to all
Netbeans doesn't like Thread.yield()

When ever I try to use Thread.yield (in my vision thread), NetBeans complains with "invoking yield() on java.lang.Thread" (just a warning, not an error).

I'd prefer to have code with no warnings, and am concerned that I'm not doing this right.

Here's the faulty class. Another class creates the thread object and calls start() on it.
Code:
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.camera.AxisCamera;
import edu.wpi.first.wpilibj.image.ColorImage;
import edu.wpi.first.wpilibj.image.BinaryImage;

public class Vision implements Runnable {
	AxisCamera    axis;
	ColorImage    colimage;
	MonoPosterize posterize;
	BinaryImage   binimage;
	Thread        thread;

	// Updates the target positions if a new image exists.
	public void refresh() {
		try {
			if (colimage != null) colimage.free();
			colimage = axis.getImage();
			if (binimage != null) binimage.free();
			binimage = posterize.posterize(colimage);
			System.out.println(binimage.getNumberParticles());
			System.out.println(binimage.getParticleAnalysisReport(0));

		} catch (Exception e) {
			System.out.println(e);
		}
	}
	
	private void WaitForImage() {
		while (!axis.freshImage()) {
			Thread.yield();
		}
	}
	
	// This is run by Thread.start();
	public void run() {
		thread = Thread.currentThread();
		thread.setPriority(Thread.MIN_PRIORITY);
	}
}
Can someone verify that I'm coding this correctly?
Reply With Quote
 


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 08:32 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