여러 스레드가 동시에 웹 서버의 파일에 대한 디렉토리를 폴링 할 수 있지만이 코드는 스레드 안전성이 있다고 간주됩니까?내 방법의 안전함
감사합니다, 마이크 Get a testimonial
코멘트에서 통화의 대부분
//Get a testimonial
virtualRoot = HostingEnvironment.ApplicationVirtualPath;
configuration = WebConfigurationManager.OpenWebConfiguration(virtualRoot);
pathToNewsDirectory = configuration.AppSettings.Settings["VanHinoWeb.news.dir"].Value;
fileListing = Directory.GetFiles(pathToNewsDirectory, "*xml");
int index = generator.Next(0, fileListing.Length);
//Put it into XML and get data into string array to return
testimonialReader = new XmlTextReader(fileListing[index]);
testimonialReader.ReadToFollowing("quote");
testimonialData[0] = testimonialReader.ReadString();
testimonialReader.ReadToFollowing("author");
testimonialData[1] = testimonialReader.ReadString();
testimonialReader.ReadToFollowing("authorTitle");
testimonialData[2] = testimonialReader.ReadString();
return testimonialData;
}
또한이 메서드에 사용 된 모든 개체가 메서드 내에서 선언되었음을 언급해야합니다. 그래서 나는 각 스레드가 자체적으로 객체 스택을 가질 것이라고 생각했습니다. –
그럼 너 괜찮을거야. – LBushkin