IntelliJ Java IDE
The moose likes Threads and Synchronization and the fly likes Spawn thread and return control to phone? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Spawn thread and return control to phone?" Watch "Spawn thread and return control to phone?" New topic
Author

Spawn thread and return control to phone?

Bill Ceglia
Ranch Hand

Joined: Dec 13, 2001
Posts: 30
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

Joined: Jan 28, 2002
Posts: 5
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
 
IntelliJ Java IDE
 
subject: Spawn thread and return control to phone?
 
Threads others viewed
testing http connection code on WirelessToolkit?
Incomming call and Midlet
Thread
Regarding autostart of a servlet
Possibility to run a midlet in back ground
developer file tools