|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
我以前很喜欢Serv-U,自从它用Java重写之后我就再也没用过,实在是太慢了,我宁可用IIS搭建FTP,虽然IIS搭建FTP在权限管理上很不灵活。Atributes:
//canaddmetadatainprogram,Itstorewiththeprogram
//usingILDasmtocheckatributes
//usage
[CodeReviewAttribute("08/08/2005","AllanZhang",
Comment="ThatisaAttributetest")]
classEmployee{}
//definetargetandatr
[AttributeUsage(AttributeTargets.Class|
AttributeTargets.Constructor|
AttributeTargets.Interface|
AttributeTargets.Method|
AttributeTargets.Field|
AttributeTargets.Property,
AllowMultiple=true)]
classCodeReviewAtrribute:System.Attribute
{
privatestringreviewDate;
privatestringreviewerName;
privatestringreviewComments;
...
}
Reflections://lookthemetadatainprogram,discory,latebinding
//DisplayattributeinCode
System.Reflection.MemberInfoinf=typeof(Employee);
object[]atributes=inf.GetCustomAttributes(false);
foreach(objectattributeinattributes)
{
CodeReviewAttributeattr=(CodeReviewAttribute)attribute;
Console.WriteLine("Thisiscodewasreviewedon{0}by{1}
Comments{2}",
attr.date,
attr.name,
attr.comment)
}
//Discovery
Assemblyasm=Assembly.Load("Mscorlib.dll");
Type[]types=asm.GetTypes();
foreach(Typetypeintypes)
{
Console.WriteLine("Typeis{0},type);
Console.WriteLine("
{0}typesfound."types.Length);
}
//LateBinding
TypemathType=Type.GetType("System.Math");
objectobj=Activator.CreaterInstance(mathType);
Type[]parameterTypes=newType[2];
parameterTypes[0]=Type.GetType("System.Double");
parameterTypes[1]=Type.GetType("System.Double");
MethodInfopowInfo=mathType.GetMethod("Pow",parameterTypes);
object[]parameters=newobject[2];
parameters[0]=5;
parameters[1]=3;
objectreturnValue=powInfo.Invoke(obj,parameters);
Console.WriteLine("5tothe3rdpoweris{0},returnValue);
Thread:
//CreateImplicitThreads
usingSystem.Threading
ThreadthreadOne=newThread(newThreadStart(Countup));
ThreadthreadTwo=newThread(newThreadStart(Countup));
threadOne.Name="ThreadOne";
threadTwo.Name="Threadtwo";
threadOne.Start();
threadTwo.Start();
//Joining&killingThreads
//jointwothreadsincurrentthrea
threadOne.start();
threadTwo.Start();
threadOne.Join();
threadTwo.Join();
//thiswillprint,aftertwoabovetwothreadsends
Console.WriteLine("Theotherthreadsdone");
//sleep(millisenconds)
threadOne.sleep(1);
threadOne.Abort();
Synchronization:
//1.noconflictbetweenthreads
interlocked.Increment(refsynchValue);
//2.lockmethod,thiswillblockotherthreadwhenitenterintoit
lock(this)
{
inttemp=synchValue;
temp++;
Thread.Sleep(2);
synchValue=temp;
synchValue=temp;
Console.WriteLine("{0}Countup:{1}",
Thread.CurrentThread.Name,
synchValue);
}
Java欺骗了我们那么多年,如今的多核时代,我认为它气数已尽! |
|