static void Main(string[] args) { int extrinsicstate = 22; FlyWeightFactory f = new FlyWeightFactory(); // Work with different flyweight instances FlyWeight fx = f.GetFlyWeight("X"); fx.Operation(--extrinsicstate); FlyWeight fy = f.GetFlyWeight("Y"); fy.Operation(--extrinsicstate); FlyWeight fz = f.GetFlyWeight("Z"); fz.Operation(--extrinsicstate); UnsharedConcreateFlyWeight fu = new UnsharedConcreateFlyWeight(); fu.Operation(--extrinsicstate); // Wait for user Console.Read(); }
static void Main(string[] args) { //Console.WriteLine("Hello World!"); for (int i = 0; i < 5; i++) { Task.Run(() => { People ch = FlyWeightFactory.GetChineseObject(FlyWeightFactory.LanguageType.Chinese); ch.Say(); }); } for (int i = 0; i < 5; i++) { Task.Run(() => { People usa = FlyWeightFactory.GetChineseObject(FlyWeightFactory.LanguageType.USA); usa.Say(); }); } Console.ReadKey(); }