摘要:
默认情况下静态字段为application domain中所有线程共享,但是使用ThreadStatic 属性可以使每个线程一份非共享的静态字段的备份。 public class Foo { [ThreadStaticAttribute( )] public static string bar = "Initialized string"; } 但是静... 阅读全文
摘要:
使用thread local storage可以将数据存储在线程的数据槽(data slot)中。数据只能被此线程访问。 1class Data 2{ 3 //Application data is stored here 4} 5 6Data appData = new Data(); 7 8Thread.SetData(Thread.GetNamedDataSlot("MyTestSl... 阅读全文
摘要:
一次处理字符串中一个字符 你可以建立一个list,其中各项是字符串中字符(在Python中没有字符(characters)和字符串(string)进行区分,字符就是长度为一的字符串)。调用内建的list,字符串为它的参数。thelist = list(thestring)你甚至可以不需要list,使用for表达式直接在字符串上循环。 for c in thestring:... 阅读全文