Click here to Skip to main content
15,896,063 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: What did he want to lock? Pin
Jeroen De Dauw9-Jun-10 4:56
Jeroen De Dauw9-Jun-10 4:56 
GeneralRe: What did he want to lock? Pin
Andrew Rissing9-Jun-10 4:12
Andrew Rissing9-Jun-10 4:12 
GeneralRe: What did he want to lock? Pin
NavnathKale9-Jun-10 8:24
NavnathKale9-Jun-10 8:24 
GeneralRe: What did he want to lock? Pin
David Skelly9-Jun-10 22:37
David Skelly9-Jun-10 22:37 
GeneralRe: What did he want to lock? Pin
Daniel Grunwald10-Jun-10 6:58
Daniel Grunwald10-Jun-10 6:58 
GeneralRe: What did he want to lock? Pin
supercat910-Jun-10 8:52
supercat910-Jun-10 8:52 
GeneralRe: What did he want to lock? Pin
Gary R. Wheeler13-Jun-10 11:41
Gary R. Wheeler13-Jun-10 11:41 
GeneralRe: What did he want to lock? Pin
supercat914-Jun-10 6:08
supercat914-Jun-10 6:08 
Gary R. Wheeler wrote:
An instance member marked private can be the lock value, manipulated solely by members of the class, like this


In your example, the lock is released between calls to the object's functions. If you used the Monitor.* functions, you could have have your code hold a lock when a function returns, but doing so would be even more dangerous than publicly exposing the lock object.

The main danger of publicly exposing a lock object is that there's no way the code for the class to protect against deadlock. Having a function which returns while a lock is held poses a much bigger danger, which is that the lock might be accidentally abandoned while it is held.
GeneralRe: What did he want to lock? Pin
Gary R. Wheeler14-Jun-10 13:51
Gary R. Wheeler14-Jun-10 13:51 
GeneralRe: What did he want to lock? Pin
supercat915-Jun-10 5:47
supercat915-Jun-10 5:47 
GeneralRe: What did he want to lock? Pin
peterchen10-Jun-10 3:26
peterchen10-Jun-10 3:26 
GeneralRe: What did he want to lock? Pin
bougiefever14-Jun-10 11:19
bougiefever14-Jun-10 11:19 
GeneralFML, Edition 6580 Pin
Wes Jones8-Jun-10 13:56
Wes Jones8-Jun-10 13:56 
GeneralRe: FML, Edition 6580 Pin
Luc Pattyn8-Jun-10 14:33
sitebuilderLuc Pattyn8-Jun-10 14:33 
GeneralRe: FML, Edition 6580 Pin
Wes Jones8-Jun-10 14:58
Wes Jones8-Jun-10 14:58 
GeneralRe: FML, Edition 6580 Pin
Jeroen De Dauw8-Jun-10 19:49
Jeroen De Dauw8-Jun-10 19:49 
Generaluseless... Pin
Noman Aftab6-Jun-10 21:53
Noman Aftab6-Jun-10 21:53 
GeneralRe: useless... Pin
Jeroen De Dauw6-Jun-10 22:55
Jeroen De Dauw6-Jun-10 22:55 
GeneralRe: useless... Pin
J4amieC6-Jun-10 23:44
J4amieC6-Jun-10 23:44 
GeneralRe: useless... Pin
supercat97-Jun-10 6:08
supercat97-Jun-10 6:08 
GeneralRe: useless... PinPopular
J4amieC7-Jun-10 6:31
J4amieC7-Jun-10 6:31 
GeneralRe: useless... Pin
supercat97-Jun-10 8:52
supercat97-Jun-10 8:52 
GeneralRe: useless... Pin
PIEBALDconsult8-Jun-10 3:21
mvePIEBALDconsult8-Jun-10 3:21 
GeneralRe: useless... Pin
Hired Mind13-Jul-10 10:23
Hired Mind13-Jul-10 10:23 
GeneralWhen you got your numbers, who needs other types Pin
Yusuf3-Jun-10 8:12
Yusuf3-Jun-10 8:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.