摘要 |
A method and apparatus for managing environment variables of a user process in an information handling system having a plurality of simultaneously running threads of execution. Thread-level set and get functions invoked by a subject thread are defined to manage environment variables of the subject thread at the thread level rather than at the process level. In response to a request to set the value of a thread-level environment variable, a thread-level set function determines whether a thread-specific environment has already been created for the subject thread. If so, the set function inserts the thread-level environment variable in the thread-specific environment. Otherwise, the set function creates a thread-specific environment and inserts the thread-level environment variable in the newly created thread-specific environment. In response to a request to obtain the value of a thread-level environment variable, a thread-level get function determines whether a thread-level environment variable has been defined for the subject thread. If so, the get function returns the thread-level environment variable. Otherwise, the get function returns the corresponding process-level environment variable. The thread-level environment created for a subject thread is destroyed when subject thread is terminated.
|