Query:lock by virtual object!

Discussion in 'Java' started by Jack Dowson, May 4, 2007.

  1. Jack Dowson

    Jack Dowson Guest

    Hello Everybody:
    I saw a demo as follow shows how to use virtual object to lock key
    resources in order to maintain synchronizing if there are several threads.

    class ClassName implements Runnable{
    String str = " ";
    public void run(){
    ...
    synchronized(str){...}
    }
    }

    I just can't understand how it works?

    Any help will be greatly appreciated!

    Dowson!
     
    Jack Dowson, May 4, 2007
    #1
    1. Advertisements

  2. Jack Dowson

    Jack Dowson Guest

    Jack Dowson дµÀ:
    > Hello Everybody:
    > I saw a demo as follow shows how to use virtual object to lock key
    > resources in order to maintain synchronizing if there are several threads.
    >
    > class ClassName implements Runnable{
    > String str = " ";
    > public void run(){
    > ...
    > synchronized(str){...}
    > }
    > }
    >
    > I just can't understand how it works?
    >
    > Any help will be greatly appreciated!
    >
    > Dowson!

    This question is really stupid!

    Dowson!
     
    Jack Dowson, May 4, 2007
    #2
    1. Advertisements

  3. Jack Dowson

    Z. Guest

    Jack Dowson wrote:
    > Hello Everybody:
    > I saw a demo as follow shows how to use virtual object to lock key
    > resources in order to maintain synchronizing if there are several threads.
    >
    > class ClassName implements Runnable{
    > String str = " ";
    > public void run(){
    > ...
    > synchronized(str){...}
    > }
    > }
    >
    > I just can't understand how it works?
    >
    > Any help will be greatly appreciated!
    >
    > Dowson!


    http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html,
    also:
    http://java.sun.com/docs/books/tutorial/essential/concurrency/syncmeth.html
     
    Z., May 4, 2007
    #3
    1. Advertisements

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. Natty Gur
    Replies:
    2
    Views:
    473
    Manfred Braun
    Jul 21, 2003
  2. Ron Vecchi

    When to lock application object

    Ron Vecchi, Jul 26, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    527
    Ron Vecchi
    Jul 26, 2003
  3. Aaron Davies
    Replies:
    2
    Views:
    480
    Chris Uppal
    Jun 25, 2004
  4. Razvan
    Replies:
    4
    Views:
    422
    Chris Uppal
    Sep 3, 2004
  5. Fuzzyman
    Replies:
    3
    Views:
    728
    Andrew MacIntyre
    Dec 5, 2003
  6. Matty J
    Replies:
    0
    Views:
    543
    Matty J
    May 13, 2008
  7. k3xji
    Replies:
    7
    Views:
    1,079
    Gabriel Genellina
    Dec 30, 2008
  8. nano2k

    Application.Lock()/UnLock() or lock(Application)

    nano2k, Jul 23, 2007, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    505
    nano2k
    Aug 9, 2007
Loading...