deadlock and thread

Discussion in 'Java' started by focode, Dec 1, 2009.

  1. focode

    focode Guest

    i am a j2me programmer and facing some problem , problem statement is
    as follows ..

    i have "main" java program usually called as midlet , and several
    other java programs which is called by the main program to perform
    several task such as sending and receiving sms etc.

    my main program send sms to a particular number eg "53030" and waits
    for sms to be received in the j2me application , sms comming from
    server takes some time , in the mean time , my application is hanged ,
    and as soon as the sms is received , hanging problem or deadlock
    situation come to an end , if i use threads i think this problem will
    be eliminated , i need suggestion as to how to implement thread and
    eliminate my problem .

    sms recieving program contains a mandatory fuction, that does the job
    of listening the sms .

    any solution will be of general type as it is implemented in j2se .

    pseudo implementation of the programs are as follows :

    // structure of main program
    public class main_program
    {

    public static void main (String str[])
    {

    sms s = new sms() // when this fuction is called my
    application goes into deadlock state
    String sms_recevied = s.listen(); // calling the
    sms class to receive sms
    System.out.println(sms_recevied); // printing the
    sms received
    }
    }
    // structure of the sms listenning program
    public class sms
    {
    String listen()
    {
    String sms_recieved = // incoming sms is
    recieved here

    return sms_recieved;

    }
    }

    if any one can help me to implement it through java thread so that no
    deadlock occurs.

    thanks and regards
    Arunesh
    focode, Dec 1, 2009
    #1
    1. Advertising

  2. focode

    Roedy Green Guest

    On Tue, 1 Dec 2009 06:56:25 -0800 (PST), focode
    <> wrote, quoted or indirectly quoted someone
    who said :

    >i am a j2me programmer and facing some problem , problem statement is
    >as follows ..
    >
    >i have "main" java program usually called as midlet , and several
    >other java programs which is called by the main program to perform
    >several task such as sending and receiving sms etc.
    >
    >my main program send sms to a particular number eg "53030" and waits
    >for sms to be received in the j2me application , sms comming from
    >server takes some time , in the mean time , my application is hanged ,
    >and as soon as the sms is received , hanging problem or deadlock
    >situation come to an end , if i use threads i think this problem will
    >be eliminated , i need suggestion as to how to implement thread and
    >eliminate my problem .
    >
    >sms recieving program contains a mandatory fuction, that does the job
    >of listening the sms .
    >
    >any solution will be of general type as it is implemented in j2se .
    >
    >pseudo implementation of the programs are as follows :
    >
    >// structure of main program
    >public class main_program
    >{
    >
    > public static void main (String str[])
    > {
    >
    > sms s = new sms() // when this fuction is called my
    >application goes into deadlock state
    > String sms_recevied = s.listen(); // calling the
    >sms class to receive sms
    > System.out.println(sms_recevied); // printing the
    >sms received
    > }
    >}
    > // structure of the sms listenning program
    >public class sms
    >{
    > String listen()
    > {
    > String sms_recieved = // incoming sms is
    >recieved here
    >
    > return sms_recieved;
    >
    > }
    >}
    >
    >if any one can help me to implement it through java thread so that no
    >deadlock occurs.
    >
    >thanks and regards
    >Arunesh


    I think all you are trying to do is put this code in the background so
    that nothing ties up while it waits for a response.

    See http://mindprod.com/jgloss/thread.html

    I suspect you are using the word "deadlock" in some non-standard way:

    See http://mindprod.com/jgloss/deadlock.html
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    I mean the word proof not in the sense of the lawyers, who set two half proofs equal to a whole one, but in the sense of a mathematician, where half proof = 0, and it is demanded for proof that every doubt becomes impossible.
    ~ Carl Friedrich Gauss
    Roedy Green, Dec 5, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DiscoStu

    Thread DEADLOCK problems! Help!

    DiscoStu, Sep 19, 2003, in forum: Java
    Replies:
    10
    Views:
    621
    David Zimmerman
    Sep 21, 2003
  2. rajatag
    Replies:
    6
    Views:
    4,401
  3. Pallav singh

    Regarding Thread deadlock

    Pallav singh, Jan 16, 2008, in forum: C++
    Replies:
    3
    Views:
    309
    Michael Oswald
    Jan 16, 2008
  4. Daniel Cuculescu

    deadlock when using waitOne in a STA thread

    Daniel Cuculescu, Jun 5, 2008, in forum: ASP .Net
    Replies:
    0
    Views:
    2,050
    Daniel Cuculescu
    Jun 5, 2008
  5. Replies:
    2
    Views:
    102
Loading...

Share This Page