Results 1 to 8 of 8

Thread: Java/J2EE Xpert group

  1. #1

    Thumbs up Java/J2EE Xpert group

    How can we achieve communication between two threads?


  2. #2
    Junior Member
    Join Date
    Nov 2005
    Answers
    3

    Re: Java/J2EE Xpert group

    Using shared objects.


  3. #3

    Re: Java/J2EE Xpert group

    Quote Originally Posted by realneeraj
    Using shared objects.

    can you be more elaborate?


  4. #4
    Junior Member
    Join Date
    Nov 2005
    Answers
    3

    Re: Java/J2EE Xpert group

    For example, in producer-consumer problem, we use a common object, the producer will write in the common object and the consumer will read from it. If you intend to pass some data between two threads then you can use some common object between the two. For example

    class CommonObj {

    String data;

    void put(String s) {
    data=s;
    }

    String get() {
    return data;
    }
    }

    You can pass an instace of the CommonObj class to each thread. Any thread can put some thing in the common object and other one can get it. Ofcourse you need to take care of synchronization issues.


  5. #5
    Junior Member
    Join Date
    Jan 2008
    Answers
    11

    Re: Java/J2EE Xpert group

    using wait(),notify(),notifyAll() methods


  6. #6
    Junior Member
    Join Date
    Feb 2009
    Answers
    3

    Re: Java/J2EE Xpert group

    import java.awt.*;
    import java applet.*;
    public class oval extends Applet
    {
    public static void paint (Graphics g)
    {
    g.drawoval(100,56);
    g.setcolor(98,33);
    g.filloval(98,23);
    }
    }


  7. #7

    Thumbs up Re: Java/J2EE Xpert group

    Quote Originally Posted by srikanth.kondapaneni View Post
    How can we achieve communication between two threads?
    By using the methods like notify, notifyall, wait.......we can achieve inter thread communication.


  8. #8
    Junior Member
    Join Date
    Dec 2008
    Answers
    2

    Re: Java/J2EE Xpert group

    Can any you Please Tell by code?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact