Results 1 to 2 of 2
  1. #1
    afx111 is offline Member
    Join Date
    Feb 2011
    Posts
    1
    Rep Power
    0

    Default question regarding thread code

    Hi guys, first time user here!

    what does this line of code mean???

    ==

    Object obj = new Object()

    synchronized(obj) {
    obj.wait()
    }

    ==

    Can't figure wats the objective? could someone explain in layman terms??? tks!!!

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,188
    Blog Entries
    7
    Rep Power
    24

    Default

    Quote Originally Posted by afx111 View Post
    Hi guys, first time user here!

    what does this line of code mean???

    ==

    Object obj = new Object()

    synchronized(obj) {
    obj.wait()
    }

    ==

    Can't figure wats the objective? could someone explain in layman terms??? tks!!!
    If that variable 'obj' is a variable local to a method that code snippet doesn't make sense because nobody else can notify on that object. Please supply a more sensible example (and use code tags please).

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

Similar Threads

  1. Question about 'main thread' and the thread it creates
    By ggyyree in forum Threads and Synchronization
    Replies: 11
    Last Post: 12-10-2010, 08:33 PM
  2. Thread question
    By exernet in forum New To Java
    Replies: 1
    Last Post: 12-16-2009, 10:27 AM
  3. an old question about Thread.Sleep()
    By narbeh in forum Threads and Synchronization
    Replies: 1
    Last Post: 03-25-2009, 08:12 AM
  4. Thread question
    By Moncleared in forum Advanced Java
    Replies: 5
    Last Post: 02-09-2009, 11:33 PM
  5. main thread question?
    By frejon26 in forum New To Java
    Replies: 1
    Last Post: 01-24-2008, 11:13 PM

Posting Permissions

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