• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Spawn thread and return control to phone?

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic