For a realtime java application with constantly updating UI changes, the EDT could possibly starve other business related processing threads. Is there a way in a multi-core processor assign a specific core to handling all swing related stuff leaveing the rest of the CPU cores to handle the business processes?
Asked
Active
Viewed 46 times
4
-
5AFAIK You can't schedule Java threads to particular cores – MadProgrammer Aug 09 '13 at 02:06
-
5Note that the event thread is, by definition, a single thread. If you have a multicore processor, it can't starve out the whole processor by itself. – chrylis -cautiouslyoptimistic- Aug 09 '13 at 02:13
-
@chrylis Point of pedantry: Under PlugIn/WebStart you can have multiple EDTs. – Tom Hawtin - tackline Aug 09 '13 at 02:21
-
@TomHawtin-tackline In the same application? How does that work? – chrylis -cautiouslyoptimistic- Aug 09 '13 at 02:23
-
@TomHawtin-tackline I would suspect for each individual PROCESS that would be true, but for a single instance of the JVM there can only be a single EDT – MadProgrammer Aug 09 '13 at 02:24
-
@MadProgrammer No. They're even numbered. However, an application should only see one. – Tom Hawtin - tackline Aug 09 '13 at 02:39
-
@chrylis In the same process, although application code should only normally see one. It works by outrageous hacks. – Tom Hawtin - tackline Aug 09 '13 at 02:40
-
Can you link to a writeup on it? It sounds like it might help distract me from my assembly woes! – chrylis -cautiouslyoptimistic- Aug 09 '13 at 02:45
-
@chrylis It's all in the source! ;) I don't know of any attempts to write it up. – Tom Hawtin - tackline Aug 09 '13 at 02:55
-
@ delita : http://stackoverflow.com/questions/2238272/java-thread-affinity discusses some JNI/JNA based solutions for thread affinity. Does that help in EDT(why not?) – Jayan Aug 09 '13 at 03:46
-
See @Jayan's link. If a JNI solution is not acceptable, the only other real option you have, which of course isn't simple, is to separate the business processing and UI visualization into two completely separate applications that communicate via, e.g., sockets, and run them in separate JVM's with an appropriate affinity mask set. That is, of course, a potentially major restructuring of your application, plus the overhead of IPC, so you might want to look at a JNI approach. – Jason C Aug 09 '13 at 04:29
-
@Jayan Tks for the link unfortunately most of the links are expired. Will google JNI and core affinity though. – delita Aug 09 '13 at 05:20