I l@ve RuBoard |
Using a Plain Old String: Single-ThreadedSay we want our program to keep track of the last error message we encountered and automatically decorate it with the time the message was generated. We might implement it using a global string value with helper functions to get and set the state:
As long as our program is single-threaded, we never have to worry about Get-Error() or SetError() being called at the same time on different threads, so all is well. For example, given:
the output would be something like:
|
I l@ve RuBoard |
No comments:
Post a Comment