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
N

ness2u2

@ness2u2
About
Posts
3
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Microsoft's arrogance with IE9
    N ness2u2

    But now my non-technical friends (and parents for that matter) don't give me urls starting with... "h.. t.. t.. p.. colon backslash, or wait? maybe its a foward slash.. w.. w.. w.. " etc.

    The Lounge

  • while (true) and for (; ; ) [modified]
    N ness2u2

    Depending on the language and framework's your using, there is probably a timer you could use to avoid the loop all together? If the bulk of the code in the loop is critical enough to require a lock, I wonder if it is something that would actually benefit from running in a multithreaded environment? I work mostly with C# and have seen very few scenarios where while(true) or for(;;) is the best choice. Just make sure its commented well!

    The Lounge hosting cloud question

  • while (true) and for (; ; ) [modified]
    N ness2u2

    Andrew Glow wrote:

    while(true)
    {
    lock(syncObject)
    {
    if (checkSomeCriticalCondition())
    break;
    }

    doSomeOtherStuff();
    }

    If possible, I'd move the lock{ someCriticalCondition } out to a function returning boolean. Then toss the result of that as the while condition. while(CheckCondition()){ doSomeOtherStuff(); } The semantics are identical, unless there is code before the lock... In my opinion, this displays the intent of code/loop better than having an internal break.

    The Lounge hosting cloud question
  • Login

  • Don't have an account? Register

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