B
bluestar
Hi, all:
I am rookie for coding java and I have one question about queue
class
I use one queue class: ArrayBlockingQueue to save/get my data
I read some data from HW and save into one ArrayBlockingQueue, and
then get from this ArrayBlockingQueue when needing. But it has one
error message: <java.lang.NumberFormatException: Invalid int:
"ffffff94"> when doing poll function
My simple code is below
private ArrayBlockingQueue<Byte> iReadQueueArray = new
ArrayBlockingQueue<Byte>(READBUF_SIZE, true);
byte[] rbuf = new byte[256];
iReadCnt = readfromHW(rbuf, rbuf.length); <---read data from
HW
ret = iReadQueueArray.offer( Byte.valueOf( (rbuf&0xFF) ));
//-----------------------------------------------------------------------//
public int read(byte[] buf) {
Byte mdata;
...
mdata = (Byte)iReadQueueArray.poll(); <---occur error when
polling some data
if( mdata!=null ) {
buf = (byte) (mdata.byteValue()&0xFF);
}
...
return 0;
}
//-----------------------------------------------------------------------//
How to modify offer data into the queue and poll data from the
queue?
Thank you for your help!
BR,
Alan
I am rookie for coding java and I have one question about queue
class
I use one queue class: ArrayBlockingQueue to save/get my data
I read some data from HW and save into one ArrayBlockingQueue, and
then get from this ArrayBlockingQueue when needing. But it has one
error message: <java.lang.NumberFormatException: Invalid int:
"ffffff94"> when doing poll function
My simple code is below
private ArrayBlockingQueue<Byte> iReadQueueArray = new
ArrayBlockingQueue<Byte>(READBUF_SIZE, true);
byte[] rbuf = new byte[256];
iReadCnt = readfromHW(rbuf, rbuf.length); <---read data from
HW
ret = iReadQueueArray.offer( Byte.valueOf( (rbuf&0xFF) ));
//-----------------------------------------------------------------------//
public int read(byte[] buf) {
Byte mdata;
...
mdata = (Byte)iReadQueueArray.poll(); <---occur error when
polling some data
if( mdata!=null ) {
buf = (byte) (mdata.byteValue()&0xFF);
}
...
return 0;
}
//-----------------------------------------------------------------------//
How to modify offer data into the queue and poll data from the
queue?
Thank you for your help!
BR,
Alan