J2ME Mutiple threads appending to same form?

T

timnels

I've got a TimerTask thread that's getting GPS readings every few
minutes,pushing them up to a server on the Internet, and appending
output to a form that was passed in the constructot. I've got another
thread that upon a command button scans a barcode, pushes that up to a
server, and outputs to the same form that was (again) passed in the
constuctor. Should I be able to append items to the form from multiple
threads? It seems like one thread does not recognize the other threads
items... since sometimes the one thread seems unable to delete the
other
threads items on the same form and the items get mixed together.
Any ideas? Thanks.
 
S

Shane Wealti

I think you're only supposed to do form updates from one thread. I'm
not sure if J2ME deals with this the same way but check into the
invokeLater() method which will make your updates on the event
processing thread.
 
D

Darryl Pierce

I've got a TimerTask thread that's getting GPS readings every few
minutes,pushing them up to a server on the Internet, and appending
output to a form that was passed in the constructot. I've got another
thread that upon a command button scans a barcode, pushes that up to a
server, and outputs to the same form that was (again) passed in the
constuctor. Should I be able to append items to the form from multiple
threads?

Yes, you can do that. There's nothing about the LCDUI that precludes
more than one thread appending to a Form.
It seems like one thread does not recognize the other threads
items... since sometimes the one thread seems unable to delete the
other
threads items on the same form and the items get mixed together.

Again, there's nothing in the LCDUI the prevents multi-threaded access,
and there's nothing about the Item set of classes that attaches an Item
to a particular Thread. What code are you using to identify an Item and
then remove it from the Form? Please share the code so we can examine it
together.
 
D

Darryl Pierce

Shane said:
I think you're only supposed to do form updates from one thread. I'm
not sure if J2ME deals with this the same way but check into the
invokeLater() method which will make your updates on the event
processing thread.

No, it doesn't. Swing works that way, the LCDUI does not.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top