Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Static method thread safety?

Static method thread safety?

Scheduled Pinned Locked Moved C#
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dr Herbie
    wrote on last edited by
    #1

    Hi folks, Do I need to use the [MethodImpl(MethodImplOptions.Synchronized)] attribute on statis methods, or are they implicitly thread-safe? Thanks in advance. Dr Herbie Remember, half the people out there have below average IQs.

    S 1 Reply Last reply
    0
    • D Dr Herbie

      Hi folks, Do I need to use the [MethodImpl(MethodImplOptions.Synchronized)] attribute on statis methods, or are they implicitly thread-safe? Thanks in advance. Dr Herbie Remember, half the people out there have below average IQs.

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      Static methods are like normal methods with respect to thread safety. You do need to protect them with some kind of synchronization mechanism.. By the way, are you sure you'd want to the use the MethodImpl attribute for synchronization? AFAIK, all methods with that attribute share a single lock, so if one thread is executing one method, no other thread will be able to execute *any* method with that attribute. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups