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. Advertising

  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. Advertising

  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. 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. Fuzzyman
    Replies:
    3
    Views:
    511
    Andrew MacIntyre
    Dec 5, 2003
  2. Robert Brewer
    Replies:
    0
    Views:
    501
    Robert Brewer
    Dec 5, 2003
  3. Matty J
    Replies:
    0
    Views:
    451
    Matty J
    May 13, 2008
  4. k3xji
    Replies:
    7
    Views:
    846
    Gabriel Genellina
    Dec 30, 2008
  5. nano2k

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

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

Share This Page