Package de.mhus.lib.core
Class MThreadPool
- java.lang.Object
-
- de.mhus.lib.core.MLog
-
- de.mhus.lib.core.lang.MObject
-
- de.mhus.lib.core.MThreadPool
-
- All Implemented Interfaces:
ILog,MNlsProvider,Nls,Runnable
- Direct Known Subclasses:
MThreadPoolDaemon
public class MThreadPool extends MObject implements Runnable
- Author:
- hummel To change the template for this generated type comment go to Window>Preferences>Java>Code Generation>Code and Comments
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classMThreadPool.ThreadContainer
-
Constructor Summary
Constructors Constructor Description MThreadPool()MThreadPool(Runnable _task)MThreadPool(Runnable _task, String _name)MThreadPool(String _name)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidasynchron(Runnable task)StringgetName()intgetPriority()protected RunnablegetTask()static <T> TgetWithTimeout(ValueProvider<T> provider, long timeout, boolean nullAllowed)Try every 200ms to get the value.voidinterupt()booleanisAlive()voidrun()voidsetName(String _name)voidsetPriority(int _p)static voidsleep(long _millisec)Sleeps _millisec milliseconds.MThreadPoolstart()voidstop()voidtaskError(Throwable t)
-
-
-
Field Detail
-
log
protected static Log log
-
task
protected Runnable task
-
name
protected String name
-
tc
protected MThreadPool.ThreadContainer tc
-
-
Method Detail
-
getTask
protected Runnable getTask()
-
start
public MThreadPool start()
-
setName
public void setName(String _name)
-
getName
public String getName()
-
setPriority
public void setPriority(int _p)
-
getPriority
public int getPriority()
-
stop
public void stop()
-
interupt
public void interupt()
-
sleep
public static void sleep(long _millisec)
Sleeps _millisec milliseconds. On Error (e.g. a break), it prints a stacktrace dump.- Parameters:
_millisec-
-
isAlive
public boolean isAlive()
-
taskError
public void taskError(Throwable t)
-
asynchron
public static void asynchron(Runnable task)
-
getWithTimeout
public static <T> T getWithTimeout(ValueProvider<T> provider, long timeout, boolean nullAllowed)
Try every 200ms to get the value. If the provider throws an error or return null the try will be repeated. If the time out is reached a TimeoutRuntimeException will be thrown.- Parameters:
provider-timeout-nullAllowed-- Returns:
- The requested value
-
-