• Post Reply Bookmark Topic Watch Topic
  • New Topic

Spawn thread and return control to phone?

 
Bill Ceglia
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to start a MIDlet, which spawns a thread, then return control to the phone so the user can operate the phone normally, but still have the thread running in the background? If so can you provide reference material or examples?
 
Derek Smith
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have done what you are asking by putting thread creation and starting in the commandAction() routine of the Midlet. This is a common way to handle background/multithreaded network connections, etc.

else if (c == cmdGo) {
//call login routine
frmProgress.setCommandListener(this);
disMain.setCurrent(frmProgress);

String strUID = txtUID.getString();
String strPIN = txtPIN.getString();

//create thread for login
INETThread login = new INETThread(INETThread.LOGIN, strUID, strPIN);
login.start();
The thread will run but any code that follows from the .start() will allow control of phone by user..so you can display a screen, etc.
Check out http://wireless.java.sun.com/midp/articles/threading/ for good example.
DMS
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!