On Friday, September 23, 2011 13:29:08 Jonathan Crapuchettes wrote: > I'm working on an application that requires a large number of strings that > only need to be loaded once at runtime and need to be accessible to all > threads throughout the execution of the program. Some of these strings are > variables like database host and username that need to be read from a file. > > Can anyone help me with an example how they might do this task? > Thank you, > JC
immutable string1; immutable string2; immtuable string3; static shared this() { string1 = "the string"; string2 = "the other string"; string3 = funcThatGrabsStringFromFile(); } immutable variables are implicitly shared. The shared module constructor will then initialize them before main runs, and all threads will have access to them. - Jonathan M Davis