×

Discussion Board

Results 1 to 13 of 13

Hybrid View

  1. #1
    Registered User
    Join Date
    Jul 2007
    Location
    Paris, France
    Posts
    41

    Multiple threads created by the mobile ??

    Hi
    I'm having a strange problem here. When I start my application I log the result of Thread.currentThread().getName(): it says "Thread-2".

    Then, I create a form with commands, classic stuff; when I click a command, I log again the result of Thread.currentThread().getName(), and this time I get "Thread-1".

    I was under the impression that my entire application was executing in a single thread, unless I create other threads myself. I keep hearing about "the UI thread", isn't that the one created at startup and that should be the one and only application thread?

    What's going on ? How many more threads should I expect? And, do I have to start worrying about synchronizing stuff? This is on a Nokia 6131 by the way.

    Thanks
    (ah, the irony of clicking on "submit new thread"....)

  2. #2
    Regular Contributor
    Join Date
    Jun 2008
    Location
    Tel-Aviv,Israel
    Posts
    100

    Re: Multiple threads created by the mobile ??

    Hi,
    Check You O/S On the Phone..
    AFAIK - S40 is Single Threaded, S60 is Multi Threaded.
    CHeck over S40 if you are able to initiate sub threads in MIDlets...
    you are able to do it in S60.
    Y

  3. #3
    Registered User
    Join Date
    Jul 2007
    Location
    Paris, France
    Posts
    41

    Re: Multiple threads created by the mobile ??

    AFAIK the 6131 runs S40; but yes, I am able to create threads.

    The problem here is that apparently the OS is running my app with multiple threads that *it*, not me, decides to create.

    I would just like to know when the OS creates threads like that and generally what to expect.

    For example, I have a class that has synchronized methods lock() and unlock(). My idea was to store the thread that locked, and when unlocking, check that it is the same thread unlocking that did the locking. If is isn't, then throw an IllegalStateException because my application has a bug.

    But it my calls to lock() are coming from random OS-created threads, obviously this strategy isn't going to work.

    I'm surprised that I'm the only one running into this problem.

  4. #4
    Regular Contributor
    Join Date
    Jun 2008
    Location
    Tel-Aviv,Israel
    Posts
    100

    Re: Multiple threads created by the mobile ??

    i have read the exact thing you wish for in this link:
    http://developers.sun.com/mobility/m...es/threading2/
    Y

  5. #5
    Registered User
    Join Date
    Jul 2007
    Location
    Paris, France
    Posts
    41

    Re: Multiple threads created by the mobile ??

    Thank you but this general intro to threads does not answer my specific question at all.

  6. #6
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: Multiple threads created by the mobile ??

    I do not have answer for you for your question on why the thread name is different. But, if you are not creating threads by yourself, you do not need to worry about synchronization.
    Out of curiosity, where do you log the name of the thread using the start-up? In MIDlet constructor? StartApp?

    ypele, You can create threads on Series 40 phones. That is sort of requirement if the phone claims to support MIDP. (How those threads are implemented under the hood is different thing)
    The fact that running multiple applications on Series 40 is not possible is not tied to being able to create threads in your MIDlet.

    Hartti
    Last edited by hartti; 2008-10-30 at 19:15. Reason: typos

Similar Threads

  1. S60 SDK 3rd edition FP1 Emulator problem
    By justteam in forum Symbian Tools & SDKs
    Replies: 14
    Last Post: 2010-03-23, 08:47
  2. Replies: 1
    Last Post: 2008-01-08, 09:58
  3. please helpme?.. this is the problem when mobile stolen..
    By ganngadhar in forum Symbian Networking & Messaging (Closed)
    Replies: 11
    Last Post: 2007-09-21, 07:55
  4. Replies: 0
    Last Post: 2007-09-14, 12:07
  5. sonify.org to focus on mobile device audio
    By hp3 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2004-10-16, 16:39

Posting Permissions

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