在我们写程序时,经常会用到单件模式,单件模式是一个类只拥有一个实例对象(或者拥有多个固定数量的实例对象)。下面我给出一个使用多线程的单件模式demo。
package com;
public class Single {
private static Single _instance = null;
private static Object lock = new...
分类:
编程语言 时间:
2014-12-26 13:06:52
阅读次数:
167
private static void ActivateOtherWindow(string windowName) { var other = FindWindow(null, windowName); if (other ...
private static ExecutorService exec = new ThreadPoolExecutor(8, 8, 0L,TimeUnit.MILLISECONDS, new LinkedBlockingQueue(100000),new ThreadPoolExecutor.Ca...
分类:
其他好文 时间:
2014-12-26 10:57:19
阅读次数:
155
public class StaticCacheTest { private static IDictionary _dic; private static object locker = new object(); private...
分类:
Web程序 时间:
2014-12-26 09:33:46
阅读次数:
179
private static final String ACTIVITY_TAG="MainActivity"; Log.v(MainActivity.ACTIVITY_TAG, "This is Verbose.%d"); Log.d(MainActivity.ACTIVITY_TAG, "Thi...
分类:
移动开发 时间:
2014-12-25 23:24:49
阅读次数:
284
private static byte hexValueOf(String hex) {
byte result = 0;
if (hex.charAt(0) == '0'
&& (hex.charAt(1) == 'X' || hex.charAt(1) == 'x')) {
for (int i = 2; i < hex.length(); i++) {
char...
分类:
编程语言 时间:
2014-12-25 20:34:11
阅读次数:
115
/**
* 一些通用的函数
*/
public class FunctionUtil {
private static long lastClickTime = 0;
/**
* 开始用的这种,后来就不限制,调用checkPhone方法。 判断手机格式是否正确,在注册和修改手机号码的时候用到
*
* @param mobiles
* @return true:正确的手机...
分类:
移动开发 时间:
2014-12-25 16:30:00
阅读次数:
215
/// /// Singleton泛型类 /// /// public sealed class Singleton where T : new() { private static T instance = new T(); ...
分类:
其他好文 时间:
2014-12-25 12:54:07
阅读次数:
156
[DllImport("kernel32.dll")] private static extern bool WritePrivateProfileString(string section, string key, string val, string filePath...
用到的 COM 类库:Windows Script Host Object Model -->Interop.IWshRuntimeLibrary.dll示例代码:private static void _BuildLink(){ var startUrl = "http://localhos...
分类:
其他好文 时间:
2014-12-24 11:34:35
阅读次数:
191