public final class OSTools
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static boolean |
assureMemory()
Check if memory gets tight and pauses if that is the case.
|
static boolean |
assureMemory(java.lang.String msg) |
static boolean |
assureMemory(java.lang.String msg,
float percentageUsed) |
static boolean |
assureMemory(java.lang.String msg,
float percentageUsed,
int maxPauseTime) |
static java.lang.String |
getJVMPid()
Returns the Pid of the current JVM instance.
|
static boolean |
invokeDesktopAction(java.lang.String action,
java.lang.Object arg)
Tries to invoke the given action on Desktop
|
static boolean |
isLinux()
Returns true if the OS architecture the current JVM instance is running in is Linux.
|
static boolean |
isMac()
Returns true if the OS architecture the current JVM instance is running in is Mac.
|
static boolean |
isOtherOS()
Returns true if the OS architecture the current JVM instance is running in is neither Windows, Linux nor Mac.
|
static boolean |
isWindows()
Returns true if the OS architecture the current JVM instance is running in is Windows.
|
static void |
sleep(float seconds)
Sleeps the current thread for the given number of seconds, or until the thread is interrupted.
|
static void |
sleep(float seconds,
boolean restoreInterruptedState) |
static void |
sleep(int seconds)
Sleeps the current thread for the given number of seconds, or until the thread is interrupted.
|
static void |
sleep(int seconds,
boolean restoreInterruptedState) |
static void |
sleep(long amount,
java.util.concurrent.TimeUnit unit)
Sleeps the current thread for the specified amount of time, or until the thread is interrupted.
|
static void |
sleep(long amount,
java.util.concurrent.TimeUnit unit,
boolean restoreInterruptedState) |
static void |
sleep(netrexx.lang.Rexx seconds)
Sleeps the current thread for the given number of seconds, or until the thread is interrupted.
|
static void |
sleep(netrexx.lang.Rexx seconds,
boolean restoreInterruptedState) |
static void |
sleepmillis(long milliseconds)
Sleeps the current thread for the specified number of milliseconds or until the thread is interrupted.
|
static void |
sleepmillis(long milliseconds,
boolean restoreInterruptedState) |
static void |
sleepMilliseconds(long milliseconds)
Sleeps the current thread for the specified number of milliseconds or until the thread is interrupted.
|
static void |
sleepMilliseconds(long milliseconds,
boolean restoreInterruptedState) |
static void |
sleepRandom(int minMillisecs,
int maxMillisecs)
Sleeps the current thread for a random amount of time, between the specified minimum and maximum milliseconds,
or until the thread is interrupted.
|
static void |
sleepRandom(int minMillisecs,
int maxMillisecs,
boolean restoreInterruptedState) |
static void |
sleepRandomMillis(int minMillisecs,
int maxMillisecs)
Sleeps the current thread for a random amount of time, between the specified minimum and maximum milliseconds,
or until the thread is interrupted.
|
static void |
sleepRandomMillis(int minMillisecs,
int maxMillisecs,
boolean restoreInterruptedState) |
static void |
sleepRandomUpToMillis(int maxMillisecs)
Sleeps the current thread for a random amount of time, up to the specified maximum milliseconds,
or until the thread is interrupted.
|
static void |
sleepRandomUpToMillis(int maxMillisecs,
boolean restoreInterruptedState) |
static void |
sleepSeconds(float seconds)
Sleeps the current thread for the given number of seconds, or until the thread is interrupted.
|
static void |
sleepSeconds(float seconds,
boolean restoreInterruptedState) |
static void |
sleepSeconds(int seconds)
Sleeps the current thread for the given number of seconds, or until the thread is interrupted.
|
static void |
sleepSeconds(int seconds,
boolean restoreInterruptedState) |
static void |
sleepSeconds(netrexx.lang.Rexx seconds)
Sleeps the current thread for the given number of seconds, or until the thread is interrupted.
|
static void |
sleepSeconds(netrexx.lang.Rexx seconds,
boolean restoreInterruptedState) |
public static java.lang.String getJVMPid()
public static boolean assureMemory()
msg
- the message to use in loggingpercentageUsed
- the use in percent from then the garbage collecting should start to free memorymaxPauseTime
- the maximum time fpr pausing before there will be a warning loggedtrue
if enough memory is available (possibly after pausing a while);
false
if the last pause took more than maxPauseTime.java.lang.IllegalArgumentException
- if percentageUsed not between 0.50 and 1.00, or if maxPauseTime <=10public static boolean assureMemory(java.lang.String msg)
public static boolean assureMemory(java.lang.String msg, float percentageUsed)
public static boolean assureMemory(java.lang.String msg, float percentageUsed, int maxPauseTime)
public static boolean isWindows()
public static boolean isLinux()
public static boolean isMac()
public static boolean isOtherOS()
public static boolean invokeDesktopAction(java.lang.String action, java.lang.Object arg)
action
- The action name (open, edit, print. browse, mail...)arg
- The argument to the action, must be of a supported class for the actiontrue
if the action could successfully be invoked with the given argumentDesktop
public static void sleepSeconds(netrexx.lang.Rexx seconds)
seconds
- The number of seconds to sleep for.restoreInterruptedState
- If true, restores the interrupted state of the thread when interrupted while sleeping. Defaults to true.java.lang.IllegalArgumentException
- If the number of seconds to sleep for is negative.public static void sleepSeconds(netrexx.lang.Rexx seconds, boolean restoreInterruptedState)
public static void sleep(netrexx.lang.Rexx seconds)
seconds
- The number of seconds to sleep for.restoreInterruptedState
- If true, restores the interrupted state of the thread when interrupted while sleeping. Defaults to true.java.lang.IllegalArgumentException
- If the number of seconds to sleep for is negative.public static void sleep(netrexx.lang.Rexx seconds, boolean restoreInterruptedState)
public static void sleepSeconds(int seconds)
seconds
- The number of seconds to sleep for.restoreInterruptedState
- If true, restores the interrupted state of the thread when interrupted while sleeping. Defaults to true.java.lang.IllegalArgumentException
- If the number of seconds to sleep for is negative.public static void sleepSeconds(int seconds, boolean restoreInterruptedState)
public static void sleep(int seconds)
seconds
- The number of seconds to sleep for.restoreInterruptedState
- If true, restores the interrupted state of the thread when interrupted while sleeping. Defaults to true.java.lang.IllegalArgumentException
- If the number of seconds to sleep for is negative.public static void sleep(int seconds, boolean restoreInterruptedState)
public static void sleepSeconds(float seconds)
seconds
- The number of seconds to sleep for.restoreInterruptedState
- If true, restores the interrupted state of the thread when interrupted while sleeping. Defaults to true.java.lang.IllegalArgumentException
- If the number of seconds to sleep for is negative.public static void sleepSeconds(float seconds, boolean restoreInterruptedState)
public static void sleep(float seconds)
seconds
- The number of seconds to sleep for.restoreInterruptedState
- If true, restores the interrupted state of the thread when interrupted while sleeping. Defaults to true.java.lang.IllegalArgumentException
- If the number of seconds to sleep for is negative.public static void sleep(float seconds, boolean restoreInterruptedState)
public static void sleep(long amount, java.util.concurrent.TimeUnit unit)
amount
- The amount of time to sleep for.unit
- The time unit of the amount to be slept for.restoreInterruptedState
- If true, restores the interrupted state of the thread when interrupted while sleeping. Defaults to true.java.lang.IllegalArgumentException
- If the amount is negative or the unit is null.public static void sleep(long amount, java.util.concurrent.TimeUnit unit, boolean restoreInterruptedState)
public static void sleepRandomMillis(int minMillisecs, int maxMillisecs)
minMillisecs
- The minimum number of milliseconds to sleep for.maxMillisecs
- The maximum number of milliseconds to sleep for.restoreInterruptedState
- If true, restores the interrupted state of the thread when interrupted while sleeping. Defaults to true.public static void sleepRandomMillis(int minMillisecs, int maxMillisecs, boolean restoreInterruptedState)
public static void sleepRandom(int minMillisecs, int maxMillisecs)
minMillisecs
- The minimum number of milliseconds to sleep for.maxMillisecs
- The maximum number of milliseconds to sleep for.restoreInterruptedState
- If true, restores the interrupted state of the thread when interrupted while sleeping. Defaults to true.public static void sleepRandom(int minMillisecs, int maxMillisecs, boolean restoreInterruptedState)
public static void sleepRandomUpToMillis(int maxMillisecs)
maxMillisecs
- The maximum number of milliseconds to sleep for.restoreInterruptedState
- If true, restores the interrupted state of the thread when interrupted while sleeping. Defaults to true.public static void sleepRandomUpToMillis(int maxMillisecs, boolean restoreInterruptedState)
public static void sleepMilliseconds(long milliseconds)
milliseconds
- The number of milliseconds to sleep for.restoreInterruptedState
- If true, restores the interrupted state of the thread when interrupted while sleeping. Defaults to true.java.lang.IllegalArgumentException
- If the number of milliseconds to sleep for is negative.public static void sleepMilliseconds(long milliseconds, boolean restoreInterruptedState)
public static void sleepmillis(long milliseconds)
milliseconds
- The number of milliseconds to sleep for.restoreInterruptedState
- If true, restores the interrupted state of the thread when interrupted while sleeping. Defaults to true.java.lang.IllegalArgumentException
- If the number of milliseconds to sleep for is negative.public static void sleepmillis(long milliseconds, boolean restoreInterruptedState)
Copyright © 2000-2024 OAshi S.à r.l. All Rights Reserved.