The mapping table shows the closest possible mapping of the Java threads API to the Solaris and POSIX APIs. This mapping is not exact and does not imply that you can convert a Solaris or POSIX threads program to a Java threads program (or vice versa) using the table. The table serves only to show a loose equivalence between the APIs and to some guidance to developers familiar with one API and interested in knowing its relationship to the corresponding API. A conceptual difference exists between using the Solaris APIs by way of procedural and layered programming in C, and using them by object-oriented programming techniques in Java.
The following examples show why the Java/Solaris API equivalence is loose.
The Java thread destroy method (Destroy()) is shown to correspond to POSIX pthread_cancel(). However, POSIX pthread_cancel() is incomplete without the concept of cancellation points and the use of pthread_cleanup_push() and pthread_cleanup_pop() to establish cleanup handlers around cancellation points. The Java threads API does not have a similar conceptual framework about destroying threads. In this sense, the two destroy techniques are very different.
As of JDK 1.1, the destroy() method has been deprecated.
The Java thread interrupt() method is shown as corresponding to POSIX pthread_kill(), but is quite different. Java has the concept of safe interruption points (for instance, wait()), whereas POSIX does not.
The Solaris readers/writer lock interfaces and the POSIX attributes do not have any close equivalent interfaces in Java.
Java Threads API |
Solaris Threads API |
POSIX Threads API |
---|---|---|
thr_create() | pthread_create() | |
activeCount() | ||
checkAccess() | ||
countStackFrames() | ||
currentThread() | thr_self() | pthread_self() |
destroy() | pthread_cancel() | |
dumpStack() | ||
enumerate() | ||
getName() | ||
getPriority() | thr_getprio() | pthread_ getschedparam() |
getThreadGroup() | ||
interrupt() | thr_kill() | pthread_kill() |
interrupted() | ||
isAlive() | ||
isDaemon() | ||
isInterrupted() | ||
join() | thr_join() | pthread_join() |
resume() | thr_continue() | |
run() | ||
setDaemon() |
THR_DAEMON flag | |
setName() | ||
setPriority() | thr_setprio() | pthread_ setschedparam() |
sleep() | sleep() | sleep() |
start() | ||
stop() | ||
suspend() | ||
Synchronization methods | ||
wait() | cond_wait() | pthread_cond_wait() |
notify() | cond_signal() | pthread_cond_signal() |
synchronized method synchronized statements |
mutexes |
pthread_mutexes |