×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Apr 2003
    Posts
    184

    updating current displayable

    I try to change a displayable (list to a form) and than leave it on the screen for 5 seconds.
    In order to implement it I call to Thread.sleep(5000), just after the setCurrent.
    The problem isthat the delay does occur but without changing the disply.

    Any suggestions?

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    If you call Thread.sleep() same thread as Display.setCurrent() then you are blocking the thread that has to set the current display. You have to spawn a new thread that sleeps for x seconds and then changes the screen back.

    shmoove

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    7
    Multithreading is the answer.
    If you look at the description of setCurrent in the API, it says that it returns, and then will change display when it will have time.
    Using several threads helps solving that kind of problem ...

  4. #4
    Registered User
    Join Date
    Jul 2003
    Location
    Finland, Tampere
    Posts
    1,113
    Multithreading is the answer but not the best, because it is generally recommended not to use multithreading in mobile devices if possible.

    Sun recommends using TimerTask in the splash screen case.
    You can find a tutorial on their site.
    I don't remember link, but you can easily find it using keywords like Splash Screen, TimerTask, etc.

  5. #5
    Regular Contributor
    Join Date
    Apr 2003
    Posts
    184
    Isn't timer task just an internal implementation of threads?

  6. #6
    Registered User
    Join Date
    Jul 2003
    Location
    Finland, Tampere
    Posts
    1,113
    It is a bit more complicated. Several TimerTasks run in a single Timer thread, and..
    Well, yes it's also multithreading, but it's usually much simpler for just sleeping several seconds. You also don't have to worry about any multithreading synchronization.

Posting Permissions

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