Hi guys..problem with using notify() & wait()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lateef
    New Member
    • Jul 2007
    • 1

    #1

    Hi guys..problem with using notify() & wait()

    i am learning java. in multithreading i want to put a thread to wait() and then call back it by notify() .. but i am not able to do so. can any one explain it to me by simple example..
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by Lateef
    i am learning java. in multithreading i want to put a thread to wait() and then call back it by notify() .. but i am not able to do so. can any one explain it to me by simple example..
    Cookies my friend, cookies.

    Comment

    • praveen2gupta
      New Member
      • May 2007
      • 200

      #3
      Originally posted by Lateef
      i am learning java. in multithreading i want to put a thread to wait() and then call back it by notify() .. but i am not able to do so. can any one explain it to me by simple example..
      Hi
      I gives you a brief idea for writing Multi Threading Program.

      1. Declare a class as extending the thread class.

      Ex. class classname extends Thread
      {

      }
      java.lang.threa d is a superclass for the multiple thraeding.

      2. overriding the the run method

      Ex public void run()
      {
      }

      3. create the object of main class and call start method to.

      Ex. new P().start();

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by praveen2gupta
        Hi
        I gives you a brief idea for writing Multi Threading Program.

        1. Declare a class as extending the thread class.
        That is considered bad practice: better implement the Runnable interface and
        feed that to a Thread object itself. If you extend from the Thread class you can't
        extend from another class anymore and closely ties your implementation to
        the Thread class just for utility purposes; don't do that.

        kind regards,

        Jos

        Comment

        Working...