public abstract class Thread4D
extends java.lang.Object
implements java.lang.Runnable
synchronized
keyword is not implemented by
the TotalCross VM.
Note that in PalmOS while the user is writing in the grafitti area all events
(including threads) are blocked (this is a Operating System behaviour).
Runnable
Modifier and Type | Field and Description |
---|---|
static int |
MAX_PRIORITY
The maximum priority that a thread can have.
|
static int |
MIN_PRIORITY
The minimum priority that a thread can have.
|
static int |
NORM_PRIORITY
The default priority that is assigned to a thread.
|
Constructor and Description |
---|
Thread4D()
Creates a new thread using a newly generated name in the format "Thread-n",
where "n" is the thread's ID.
|
Thread4D(java.lang.Runnable r)
Creates a new thread with the given runnable object and using a newly generated
name in the format "Thread-n", where "n" is the thread's ID.
|
Thread4D(java.lang.Runnable r,
java.lang.String name)
Creates a new thread with the given runnable object and name.
|
Thread4D(java.lang.String name)
Creates a new thread with the given name.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.Thread |
currentThread()
Returns a reference to the currently running thread.
|
long |
getId()
Returns the thread id, which is a number generated automatically.
|
java.lang.String |
getName()
Returns this thread's name.
|
int |
getPriority()
Returns this thread's priority.
|
boolean |
isAlive()
Returns true if this thread is alive.
|
void |
run()
Called by the vm to run the thread.
|
void |
setName(java.lang.String name)
Sets this thread's name.
|
void |
setPriority(int priority)
Sets the thread priority, ranging from #MIN_PRIORITY to #MAX_PRIORITY.
|
static void |
sleep(long millis) |
void |
start()
Starts a thread.
|
java.lang.String |
toString()
Returns a string representation of this thread, including the
thread's name and priority.
|
static void |
yield()
Give up on the timeslice of the current thread and goes to the next thread in the round-robin queue.
|
public static final int MIN_PRIORITY
public static final int NORM_PRIORITY
public static final int MAX_PRIORITY
public Thread4D()
public Thread4D(java.lang.String name)
name
- the name of the new thread or null
to use a newly
generated name in the format "Thread-n", where "n" is the thread's ID.public Thread4D(java.lang.Runnable r)
r
- the object whose run method is called.public Thread4D(java.lang.Runnable r, java.lang.String name)
r
- the object whose run method is called.name
- the name of the new thread or null
to use a newly
generated name in the format "Thread-n", where "n" is the thread's ID.public long getId()
public java.lang.String toString()
toString
in class java.lang.Object
public final java.lang.String getName()
public final void setName(java.lang.String name)
name
- the new name for this thread.public final int getPriority()
public final void setPriority(int priority)
start
is called, otherwise it will have no effect
(some platforms do not allow the priority change after it is started).MIN_PRIORITY
,
NORM_PRIORITY
,
MAX_PRIORITY
public final boolean isAlive()
public void run()
run
in interface java.lang.Runnable
public static void yield()
public static void sleep(long millis) throws java.lang.InterruptedException
java.lang.InterruptedException
public void start()
public static java.lang.Thread currentThread()