.wait() and .notify() methods in multithreading


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: .wait() and .notify() methods in multithreading

  1. #1
    SATISH Guest

    .wait() and .notify() methods in multithreading


    pls let me know if anyone of you have any idea as to how to use

    .wait() and .notify() methods in multithreading...

    pls send me an example code...if u have I am trying use that and it is not
    working....

    pls see the code below....

    -----------------------------CLASS 1---------------------------------------

    if (response == JOptionPane.YES_OPTION)
    {
    depotVersion = JOptionPane.showInputDialog(parent,
    "Please enter the depotVersion:" /*13A*/);
    txtDisplay.append("Performing the OAM Upgrade " +
    '\n');
    // get ats connection, prepare data and send it
    txtOAMVersion.setText(" ");

    synchronized(syncObj)
    {
    try
    {
    callInvokeOAMUpgrade();
    syncObj.wait();
    new FireCurrentVersion();
    }
    catch (Exception e) {txtDisplay.append(e.toString());}
    }


    }

    else if (response == JOptionPane.NO_OPTION)
    {
    txtDisplay.append(" OAM Upgrade cancelled" + '\n');
    }
    btnOAMRollback.setEnabled(true);
    btnOAMUpgrade.setEnabled(true);

    ---------------------------------------------------------------------------------------------------------------

    ----------------------CLASS 2---------------------------------------------------------------
    class FireCurrentVersion extends Thread
    {

    FireCurrentVersion()
    {
    this.start();
    }

    public void run()
    {
    synchronized(syncObj)
    {
    try
    {
    callCurrentVersion();
    syncObj.notify();
    }
    catch (Exception e) { txtDisplay.append(e.toString()); }
    }
    }

    }

    -------------------------------------------------------------------------------------------------


  2. #2
    Randy Charles Morin Guest

    Re: .wait() and .notify() methods in multithreading

    http://java.sun.com/docs/books/tutor...AndNotify.html

    --
    Randy Charles Morin
    Author of Programming Windows Services
    http://www.kbcafe.com

    Feel free to contact me by private email or messenger
    MSN Messenger - morin_randy@hotmail.com
    Yahoo Messenger - randymorin@yahoo.com

    "SATISH" <satish_141@yahoo.com> wrote in message
    news:3c04f6ad@147.208.176.211...
    >
    > pls let me know if anyone of you have any idea as to how to use
    >
    > wait() and .notify() methods in multithreading...
    >
    > pls send me an example code...if u have I am trying use that and it is not
    > working....
    >
    > pls see the code below....
    >
    > -----------------------------CLASS

    1---------------------------------------
    >
    > if (response == JOptionPane.YES_OPTION)
    > {
    > depotVersion = JOptionPane.showInputDialog(parent,
    > "Please enter the depotVersion:" /*13A*/);
    > txtDisplay.append("Performing the OAM Upgrade " +
    > '\n');
    > // get ats connection, prepare data and send it
    > txtOAMVersion.setText(" ");
    >
    > synchronized(syncObj)
    > {
    > try
    > {
    > callInvokeOAMUpgrade();
    > syncObj.wait();
    > new FireCurrentVersion();
    > }
    > catch (Exception e)

    {txtDisplay.append(e.toString());}
    > }
    >
    >
    > }
    >
    > else if (response == JOptionPane.NO_OPTION)
    > {
    > txtDisplay.append(" OAM Upgrade cancelled" +

    '\n');
    > }
    > btnOAMRollback.setEnabled(true);
    > btnOAMUpgrade.setEnabled(true);
    >
    > --------------------------------------------------------------------------

    -------------------------------------
    >
    > ----------------------CLASS

    2---------------------------------------------------------------
    > class FireCurrentVersion extends Thread
    > {
    >
    > FireCurrentVersion()
    > {
    > this.start();
    > }
    >
    > public void run()
    > {
    > synchronized(syncObj)
    > {
    > try
    > {
    > callCurrentVersion();
    > syncObj.notify();
    > }
    > catch (Exception e) { txtDisplay.append(e.toString()); }
    > }
    > }
    >
    > }
    >
    > --------------------------------------------------------------------------

    -----------------------
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center