Results 1 to 5 of 5

Thread: [RESOLVED] SyncLock

  1. #1

    Thread Starter
    Addicted Member Filik's Avatar
    Join Date
    Aug 2005
    Posts
    208

    Resolved [RESOLVED] SyncLock

    Hi,
    in short: What's SyncLock?
    thx
    They shout: "Give us cheap oil!"
    What will they shout when all the oil is gone? "Give us another planet full of oil!"



    1 Cigarete takes away 15 minutes of life, 1 minute of laughter gives you 15 minutes of life. What should you do?
    Smoke weed!

  2. #2
    Hyperactive Member temp_12000's Avatar
    Join Date
    Jan 2004
    Location
    LA, USA
    Posts
    411

    Re: SyncLock

    it is not easy to explain it in a short time, you had better check a book for details.

    basically, if you are not using multi-thread, you do not need use it. synclock locks the variables, so multithreads can not share it at the same time.



  3. #3

    Thread Starter
    Addicted Member Filik's Avatar
    Join Date
    Aug 2005
    Posts
    208

    Re: SyncLock

    Quote Originally Posted by temp_12000
    it is not easy to explain it in a short time, you had better check a book for details.

    basically, if you are not using multi-thread, you do not need use it. synclock locks the variables, so multithreads can not share it at the same time.
    Dont think i need any more details, that very much clarifies it, but it's supposed to lock the variables for a specified thread from all the other threads, right?
    They shout: "Give us cheap oil!"
    What will they shout when all the oil is gone? "Give us another planet full of oil!"



    1 Cigarete takes away 15 minutes of life, 1 minute of laughter gives you 15 minutes of life. What should you do?
    Smoke weed!

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: SyncLock

    Only one thread can enter a SyncLock block at a time, so if one thread is currently executing code within the SyncLock block then any other threads will wait until that thread exits the block before ONE AND ONLY ONE of them enters. It is up to the system which is the lucky winner. I don't think that the order in which they arrive has any bearing on the order in which they enter. If several SyncLock blocks are passed the same object via their expressions then those SyncLock blocks are linked and no thread may enter any of them if another thread is currently executing any of them, whether it's the same block or not.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Addicted Member Filik's Avatar
    Join Date
    Aug 2005
    Posts
    208

    Re: SyncLock

    Quote Originally Posted by jmcilhinney
    Only one thread can enter a SyncLock block at a time, so if one thread is currently executing code within the SyncLock block then any other threads will wait until that thread exits the block before ONE AND ONLY ONE of them enters. It is up to the system which is the lucky winner. I don't think that the order in which they arrive has any bearing on the order in which they enter. If several SyncLock blocks are passed the same object via their expressions then those SyncLock blocks are linked and no thread may enter any of them if another thread is currently executing any of them, whether it's the same block or not.
    Thx, that covers it
    They shout: "Give us cheap oil!"
    What will they shout when all the oil is gone? "Give us another planet full of oil!"



    1 Cigarete takes away 15 minutes of life, 1 minute of laughter gives you 15 minutes of life. What should you do?
    Smoke weed!

Posting Permissions

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



Click Here to Expand Forum to Full Width