|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.sys.mThread
The mThread class is used as a substitute for the java.lang.Thread class and is used in Ewe as a convenient way of converting simple Java algorithms that use Threads to work in Ewe. A simple change of "Thread" to "mThread" will take care of most conversions.
An important thing to note is that this is not a true pre-emptive thread. This is simply a Runnable object that is run by a Coroutine. Therefore other mThreads or Coroutines will not be active while an mThread is running. Calling sleep() within an mThread will allow other Coroutines to run.
| Field Summary | |
protected boolean |
daemon
|
static int |
MAX_PRIORITY
|
static int |
MIN_PRIORITY
|
protected Runnable |
myRunnable
|
protected String |
name
|
static int |
NORM_PRIORITY
|
protected int |
priority
|
| Constructor Summary | |
mThread()
|
|
mThread(mThreadGroup group,
Runnable run)
|
|
mThread(mThreadGroup group,
Runnable run,
String name)
|
|
mThread(mThreadGroup group,
String name)
|
|
mThread(Runnable run)
|
|
mThread(Runnable run,
String name)
|
|
mThread(String name)
|
|
| Method Summary | |
static mThread |
currentThread()
Return the current running mThread. |
String |
getName()
Get the name of this thread. |
int |
getPriority()
Get the priority level of this thread. |
mThreadGroup |
getThreadGroup()
|
void |
interrupt()
|
static boolean |
inThread()
This returns true if a the current thread is a true mThread (i.e. |
boolean |
isAlive()
Checks if the thread is alive. |
boolean |
isDaemon()
Checks if this thread is a daemon thread. |
void |
join()
Wait for this mThread to die. |
void |
join(long millis)
Wait for this mThread to die for at most millis milliseconds. |
void |
join(long millis,
int nano)
Wait for this mThread to die for at most millis milliseconds. |
static boolean |
nap(int time)
If the current thread is a Coroutine thread, it will cause a sleep for the specified length of time, otherwise this call is ignored. |
static int |
nap(int iterations,
int time)
This will cause the running mThread to sleep for time (in milliseconds) every iterations calls to this method. |
void |
run()
|
void |
setDaemon(boolean daemon)
Sets whether this thread is to be a daemon thread or not - but as of 1.43 setting an thread to be a daemon thread has no effect on how the thread is treated or how it operates. |
void |
setName(String name)
Set the name of this thread. |
void |
setPriority(int newPriority)
Set the priority level of this thread. |
static void |
sleep(long millis)
Cause the current mThread to sleep for the specified length of time, unless interrupted by another thread. |
static void |
sleep(long millis,
int nanos)
Cause the current mThread to sleep for the specified length of time, unless interrupted by another thread. |
void |
start()
Start the mThread running at the soonest opportunity. |
static void |
waitForResume()
This is used with native methods where the native method must run in its own native thread. |
static boolean |
waitForResume(long millis)
This is used with native methods where the native method must run in its own native thread. |
static void |
yield()
Give other threads a chance to run. |
static void |
yield(int everyMillis)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, toString |
| Field Detail |
public static final int MAX_PRIORITY
public static final int MIN_PRIORITY
public static final int NORM_PRIORITY
protected Runnable myRunnable
protected String name
protected int priority
protected boolean daemon
| Constructor Detail |
public mThread()
public mThread(mThreadGroup group,
Runnable run,
String name)
public mThread(Runnable run)
public mThread(Runnable run,
String name)
public mThread(String name)
public mThread(mThreadGroup group,
String name)
public mThread(mThreadGroup group,
Runnable run)
| Method Detail |
public int getPriority()
public final mThreadGroup getThreadGroup()
public final void setPriority(int newPriority)
public void setName(String name)
public String getName()
public final boolean isAlive()
public final boolean isDaemon()
public final void setDaemon(boolean daemon)
daemon - true to mark this thread as a daemon thread. False otherwise.
IllegalThreadStateException - if the thread has been already started.
public static void waitForResume()
throws InterruptedException
This method is the same as waitForResume(-1).
InterruptedException - if interrupt() was called on the thread.
public static boolean waitForResume(long millis)
throws InterruptedException
millis - The maximum length of time to wait, or -1 to wait indefinitely.
InterruptedException - if interrupt() was called on the thread.
public static void sleep(long millis)
throws InterruptedException
millis - The length of time in milliseconds to sleep. A sleep of -1 will
cause
InterruptedException - - if interrupted by another thread.
public static void sleep(long millis,
int nanos)
throws InterruptedException
millis - The length of time in milliseconds to sleep.nanos - An additional time in nanoseconds to sleep.
InterruptedException - - if interrupted by another thread.public void run()
run in interface Runnablepublic static void yield()
public static void yield(int everyMillis)
public void interrupt()
public void start()
public void join()
throws InterruptedException
InterruptedException - if interrupt() was called on it.
public void join(long millis)
throws InterruptedException
millis - The maximum time to wait for the mThread to die. A value
of 0 means to wait forever.
InterruptedException - if interrupt() was called on it.
public void join(long millis,
int nano)
throws InterruptedException
millis - The maximum time to wait for the mThread to die. A value
of 0 means to wait forever.nano - An additional number of nanoseconds to wait.
InterruptedException - if interrupt() was called on it.
public static final int nap(int iterations,
int time)
public static final boolean nap(int time)
time - the length of time to nap for - it can be 0, but should not be < 0.
public static mThread currentThread()
public static boolean inThread()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||