diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/IceInternal/EndpointHostResolver.java | 22 | ||||
-rw-r--r-- | java/src/IceInternal/Instance.java | 4 | ||||
-rw-r--r-- | java/src/IceInternal/SelectorThread.java | 4 | ||||
-rw-r--r-- | java/src/IceInternal/ThreadPool.java | 31 | ||||
-rw-r--r-- | java/src/IceInternal/Util.java | 27 |
5 files changed, 82 insertions, 6 deletions
diff --git a/java/src/IceInternal/EndpointHostResolver.java b/java/src/IceInternal/EndpointHostResolver.java index d9ab1509112..c763fbca50d 100644 --- a/java/src/IceInternal/EndpointHostResolver.java +++ b/java/src/IceInternal/EndpointHostResolver.java @@ -14,9 +14,25 @@ public class EndpointHostResolver EndpointHostResolver(Instance instance) { _instance = instance; - - _thread = new HelperThread(); - _thread.start(); + try + { + _thread = new HelperThread(); + if(_instance.initializationData().properties.getProperty("Ice.ThreadPriority") != "") + { + _thread.setPriority(Util.getThreadPriorityProperty(_instance.initializationData().properties, "Ice")); + } + _thread.start(); + } + catch(RuntimeException ex) + { + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + ex.printStackTrace(pw); + pw.flush(); + String s = "cannot create thread for endpoint host resolver thread:\n" + sw.toString(); + _instance.initializationData().logger.error(s); + throw ex; + } } synchronized public void diff --git a/java/src/IceInternal/Instance.java b/java/src/IceInternal/Instance.java index bc6ec340ee1..ab73e298d64 100644 --- a/java/src/IceInternal/Instance.java +++ b/java/src/IceInternal/Instance.java @@ -728,6 +728,10 @@ public final class Instance try { _timer = new Timer(this); + if(initializationData().properties.getProperty("Ice.ThreadPriority") != "") + { + _timer.setPriority(Util.getThreadPriorityProperty(initializationData().properties, "Ice")); + } } catch(RuntimeException ex) { diff --git a/java/src/IceInternal/SelectorThread.java b/java/src/IceInternal/SelectorThread.java index d01b3ad82e1..8dfab6449c7 100644 --- a/java/src/IceInternal/SelectorThread.java +++ b/java/src/IceInternal/SelectorThread.java @@ -37,6 +37,10 @@ public class SelectorThread try { _thread = new HelperThread(); + if(_instance.initializationData().properties.getProperty("Ice.ThreadPriority") != "") + { + _thread.setPriority(Util.getThreadPriorityProperty(_instance.initializationData().properties, "Ice")); + } _thread.start(); } catch(RuntimeException ex) diff --git a/java/src/IceInternal/ThreadPool.java b/java/src/IceInternal/ThreadPool.java index f897b20fefe..917c85182de 100644 --- a/java/src/IceInternal/ThreadPool.java +++ b/java/src/IceInternal/ThreadPool.java @@ -95,6 +95,14 @@ public final class ThreadPool _stackSize = stackSize; + _hasPriority = _instance.initializationData().properties.getProperty(_prefix + ".ThreadPriority") != ""; + _priority = Util.getThreadPriorityProperty(_instance.initializationData().properties, _prefix); + if(!_hasPriority) + { + _hasPriority = _instance.initializationData().properties.getProperty("Ice.ThreadPriority") != ""; + _priority = Util.getThreadPriorityProperty(_instance.initializationData().properties, "Ice"); + } + if(_instance.traceLevels().threadPool >= 1) { String s = "creating " + _prefix + ": Size = " + _size + ", SizeMax = " + _sizeMax + ", SizeWarn = " + @@ -110,7 +118,14 @@ public final class ThreadPool EventHandlerThread thread = new EventHandlerThread(_programNamePrefix + _prefix + "-" + _threadIndex++); _threads.add(thread); - thread.start(); + if(_hasPriority) + { + thread.start(_priority); + } + else + { + thread.start(java.lang.Thread.NORM_PRIORITY); + } ++_running; } } @@ -268,7 +283,14 @@ public final class ThreadPool EventHandlerThread thread = new EventHandlerThread(_programNamePrefix + _prefix + "-" + _threadIndex++); _threads.add(thread); - thread.start(); + if(_hasPriority) + { + thread.start(_priority); + } + else + { + thread.start(java.lang.Thread.NORM_PRIORITY); + } ++_running; } catch(RuntimeException ex) @@ -997,9 +1019,10 @@ public final class ThreadPool } public void - start() + start(int priority) { _thread = new Thread(null, this, _name, _stackSize); + _thread.setPriority(priority); _thread.start(); } @@ -1075,4 +1098,6 @@ public final class ThreadPool private boolean _promote; private final boolean _warnUdp; + private int _priority; + private boolean _hasPriority = false; } diff --git a/java/src/IceInternal/Util.java b/java/src/IceInternal/Util.java index b55c23fdca5..12b0792b06d 100644 --- a/java/src/IceInternal/Util.java +++ b/java/src/IceInternal/Util.java @@ -123,4 +123,31 @@ public final class Util return null; } + + public static int + getThreadPriorityProperty(Ice.Properties properties, String prefix) + { + String pri = properties.getProperty(prefix + ".ThreadPriority"); + if(pri.equals("MIN_PRIORITY") || pri.equals("java.lang.Thread.MIN_PRIORITY")) + { + return java.lang.Thread.MIN_PRIORITY; + } + else if(pri.equals("NORM_PRIORITY") || pri.equals("java.lang.Thread.NORM_PRIORITY")) + { + return java.lang.Thread.NORM_PRIORITY; + } + else if(pri.equals("MAX_PRIORITY") || pri.equals("java.lang.Thread.MAX_PRIORITY")) + { + return java.lang.Thread.MAX_PRIORITY; + } + + try + { + return Integer.parseInt(pri); + } + catch(NumberFormatException ex) + { + } + return java.lang.Thread.NORM_PRIORITY; + } } |