public NamedThreadFactory(string preffix, bool daemon) { SecurityManager s = java.lang.System.getSecurityManager(); group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); namePrefix = preffix + "-" + poolNumber.getAndIncrement() + "-thread-"; isDaemon = daemon; }
/// <summary> /// Create a thread. /// </summary> /// <seealso cref= ThreadFactory#newThread(java.lang.Runnable) </seealso> public virtual java.lang.Thread newThread(Runnable r) { java.lang.Thread thread = new java.lang.Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0); thread.setDaemon(isDaemon); if (thread.getPriority() != Thread.NORM_PRIORITY) { thread.setPriority(Thread.NORM_PRIORITY); } return(thread); }
public CustomThreadFactory(string namePrefix, bool daemon, int priority) { if (priority > Thread.MAX_PRIORITY || priority < Thread.MIN_PRIORITY) { throw new IllegalArgumentException("illegal thread priority"); } SecurityManager s = java.lang.System.getSecurityManager(); this.group = s != null?s.getThreadGroup() : Thread.currentThread().getThreadGroup(); this.namePrefix = namePrefix + "-" + poolNumber.getAndIncrement() + "-thread-"; this.daemon = daemon; this.priority = priority; }
public Thread newThread(Runnable r) { Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0); if (t.isDaemon() != daemon) { t.setDaemon(daemon); } if (t.getPriority() != priority) { t.setPriority(priority); } return(t); }
/// <summary> /// increase the reference count /// </summary> public virtual void increaseRef() { referenceCount.getAndIncrement(); }