public final class NativeServices
extends java.lang.Object
Since the methods in this class require the presence of a shared library with the name defined in SHLIB_NAME it is necessary to load it prior to making use of any such methods. All methods that require the shared library will automatically load the library if that has not been already done. The library might also be manually loaded with the 'loadLibrary()' method of this class.
This class provides only static methods. It should not be instantiated.
Currently the only native services available is settings relative to POSIX threads, which are not accessible from the Java API.
Currently the methods in this class make sense with POSIX threads only, since they access POSIX threads settings. POSIX threads are most used under UNIX and UNIX-like operating systems and are mostly referred to as "native" threads in Java Virtual Machine (JVM) implementations.
The shared library SHLIB_NAME uses functions of the POSIX thread library (i.e. 'pthread'). Calling the methods that use the 'pthread' library will most prbably cause the Java Virtual Machine (JVM) to crash if it is not using the POSIX threads, due to unsatisfied references. For instance, JVMs that use "green" threads will most certainly crash. POSIX threads are referred to as "native" threads in JVMs under UNIX operating systems.
On Operating Systems where POSIX threads are not available (typically Windows 95/98/NT/2000, MacIntosh, OS/2) there is no problem since the SHLIB_NAME, if available, will not make use of POSIX threads library functions, thus no problem should occur.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SHLIB_NAME
The name of the shared library containing the implementation of the
native methods: 'jj2000'.
|
Modifier and Type | Method and Description |
---|---|
static int |
getThreadConcurrency()
Returns the current concurrency level.
|
static boolean |
loadLibrary()
Loads the shared library implementing the native methods of this
class and returns true on success.
|
static void |
setThreadConcurrency(int n)
Sets the concurrency level of the threading system of the Java Virtual
Machine (JVM) to the specified level.
|
public static final java.lang.String SHLIB_NAME
public static void setThreadConcurrency(int n)
For JVM implementations that use POSIX threads with PTHREAD_SCOPE_SYSTEM scheduling scope or JVM implementations that use Windows(R) threads and maybe others, setting the concurrency level has no effect. In this cases the number of CPUs that can be exploited by the JVM is not limited in principle, all CPUs are available to the JVM.
For JVM implementations that use "green" threads setting the concurrency level, and thus calling this method, makes no sense, since "green" threads are all contained in one user process and can not use multiple CPUs. In fact calling this method can result in a JVM crash is the shared library SHLIB_NAME has been compiled to use POSIX threads.
n
- The new concurrency level to set.java.lang.IllegalArgumentException
- Concurrency level is negativejava.lang.UnsatisfiedLinkError
- If the shared native library
implementing the functionality could not be loaded.public static int getThreadConcurrency()
setThreadConcurrency(int)
public static boolean loadLibrary()
Copyright © 2014 Open Microscopy Environment