Java C# 同步 互斥
1. 在C#中有 ManualResetEvent 可用在线程间同步,那在JAVA中有类似的类吗?
2. 在C#中有 MethodInvoker, 它是可以绑定一个事件处理函数, 还是没有限制?
MethodInvoker mi += handle1();
mi += handle2();
if(mi != null)mi();
*********************************
是handle1() or handle2() or together 响应?
*********************************
3. JAVA中没有MethodInvoker, 我自造了一个(这样代吗的修改可以少些)
interface MethodInvoker{
public void onMethodInvoker();
}
And also write function "setOnMethodInvokerListener(MethodInvoker onMethodInvoker)" in the event original source class.
But the code in C# used as this:
CommandLogon(userName, pwd, delegete{faile=0;}, delegete{faile=1;}, delegete{faile=2;});
The construction method : CommandLogon(string , string , MethodInvoker , MethodInvoker , MethodInvoker );
***************************************************************************************************
What can I do as to make a common MethodInvoker , as you see, my current MethodInvoker no parameters?
***************************************************************************************************
4. As to support the situation that multiple Handlers can be added to one MethodInvoker , I create a MethodInvokerGroup .
Just use a Set<MethodInvoker> onMethodInvokers to achieve that by
for(MethodInvoker mi : onMethodInvokers){mi.onMethodInvoker();}
At the same time , I have use List<> for another Event-Handler .
*********************************
Which is better ? List or Set ? (ArrayList/HashSet)
*********************************