Discussion Board

Results 1 to 2 of 2

Thread: eSWT threading

  1. #1
    Registered User
    Join Date
    Jan 2010

    eSWT threading

    I am using eSWT on s60 5ed and if I want to do something time consuming, like sockets or http, can I do it like;
    Runnable runnable = new Runnable() {
        public void run() {
    Or should I do it in my own thread;
    Runnable runnable = new Runnable() {
        public void run() {
    new Thread(runnable).start();
    I only ask because I hate to keep creating new threads and I if eSWT is designed to handle this already. I was just concerned that maybe it would not be efficient if I used the Display.asyncExec(Runnable); method. Any ideas?

    coolies thanx in advance!

  2. #2
    Nokia Developer Expert
    Join Date
    Nov 2008

    Re: eSWT threading

    It is really important that eSWT's UI thread is used only for UI related work. UI thread actually dispatches the UI events and unless UI thread respons promptly UI may become sluggish or get stuck completely.

    What Display.asyncExec() does essentially is it calls the run method of the Runnable in the UI thread in the next Display.readAndDispatch call series. In your case run method will possibly be blocking which will cause your UI performance to suffer. So it is better to reserve one thread for non-ui work and update the UI using the Display.asyncExec(),Display.syncExec() if needed.

    Having a second thread in addition to UI thread may sound like an overkill but this is actually how it works with all other UI toolkits as well. For instance, LCDUI also keeps a second thread behind the scenes for UI work. Therefore the overall cost to the system is not different with eSWT & LCDUI, the only thing different is eSWT gives you more control.

Similar Threads

  1. HOW:Custom ListBox in eSWT or LCDUI
    By mackrispi in forum Mobile Java General
    Replies: 5
    Last Post: 2009-09-14, 15:54
  2. JSR-135 (camera) and eSWT integration
    By jredfern in forum Mobile Java Media (Graphics & Sounds)
    Replies: 6
    Last Post: 2009-08-18, 13:10
  3. Rich Text editor/UI in eSWT
    By subhodeep in forum Mobile Java General
    Replies: 1
    Last Post: 2009-03-10, 11:11
  4. Replies: 3
    Last Post: 2009-01-09, 18:53
  5. threading help J2ME
    By shirodas in forum Mobile Java General
    Replies: 4
    Last Post: 2008-12-02, 05:25

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts