Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple tasks processed by a java thread are delaying another java thread
    text
    copied!<p>One of the things a core java server i'm running does is process two type of tasks (T1 and T2) . Originally these tasks were being processed from the same queue and thread. At times the queue contains about 1000 T1 tasks which cause delays for the next T2 task. So i decided to change the architecture and process each task in a separate thread and separate queue. But it looks like the JVM will still process the ~1000 T1 tasks (about .6 seconds) before switching to the other thread and processing T2 tasks. </p> <p>I'm running on a quad core machine running "Red Hat Enterprise Linux Server release 6.1 (Santiago)". </p> <p>I'm assuming that the two threads are being run on the same CPU. </p> <p>Is there any way to facilitate the OS or JVM to switch more often? Also is there a way to see which thread is being processed by which processor?</p> <p>I've verified that both threads are running as separate threads using a debugger.</p> <p>One thread is created using</p> <pre><code>this.executor.Executors.newSingleThreadExecutor(); </code></pre> <p>And tasks are submitted using</p> <pre><code>executor.submit(new Task2(..)); </code></pre> <p>The other thread is legacy code that manages it's own queue:</p> <pre><code>private final BlockingQueue&lt;...&gt; workQueue = new LinkedBlockingQueue&lt;...&gt;(); .... public void submit(Task1 task) { workQueue.add(task); } .... public void run() { while (alive){ try{ Task1 task = workQueue.take(); processwork(task); } .... </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload