starting thread inside synchronized block

Discussion in 'Java' started by John Davison, Feb 17, 2004.

  1. John Davison

    John Davison Guest

    If I start a new thread inside a synchronized (object) block, that thread
    doesn't inherit the monitor on object, does it?

    Thanks!

    John Davison
     
    John Davison, Feb 17, 2004
    #1
    1. Advertising

  2. "John Davison" <> writes:

    > If I start a new thread inside a synchronized (object) block, that thread
    > doesn't inherit the monitor on object, does it?


    You misunderstand: Monitors aren't tied to threads but to objects.
    Threads "take" and "release" the sync-object's monitor when they enter
    or exit synchronized code. So the Thread you create will not be
    associated with a monitor until it enters a synchronized block while
    running, the two threads are not related. (Except through a
    ThreadGroup if you want them to be.)
     
    Tor Iver Wilhelmsen, Feb 17, 2004
    #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. Jerry
    Replies:
    4
    Views:
    131,847
    tonni
    Aug 11, 2010
  2. Pep
    Replies:
    6
    Views:
    29,280
  3. dmcreyno
    Replies:
    9
    Views:
    9,567
    Mark Space
    Jun 27, 2006
  4. morrell
    Replies:
    1
    Views:
    965
    roy axenov
    Oct 10, 2006
  5. ankur
    Replies:
    4
    Views:
    1,445
    Eric Sosman
    Nov 28, 2008
Loading...

Share This Page