eventqueue

EventQueue inconsistent ID's

一曲冷凌霜 提交于 2020-01-13 11:08:10
问题 I have a problem with the following example code that shows inconsistent behavior for the EventQueue: public static void main( String[] args ) throws InvocationTargetException, InterruptedException { final long[] id1 = new long[ 1 ]; final long[] id2 = new long[ 1 ]; EventQueue.invokeAndWait( new Runnable() { @Override public void run() { id1[ 0 ] = Thread.currentThread().getId(); } } ); Thread.sleep( 5000 ); EventQueue.invokeAndWait( new Runnable() { @Override public void run() { id2[ 0 ] =

How to replace or restart a deadlocked Swing EventDispatchThread/EventQueue in Java 8 desktop application

只愿长相守 提交于 2019-12-24 14:13:21
问题 A while back we added some code to our application to detect and attempt to recover from a Swing EDT deadlock, so the user could at least save their files (it would be best to not have a deadlock, but...). In Java 1.6, this is easy. Detect that the EDT has been blocked for a sufficient amount of time, and then call this from a background thread: EventQueue newQ = new EventQueue(); Toolkit.getDefaultToolkit().getSystemEventQueue().push(newQ); New UI events will be processed on a new EventQueue

Bloomberg API request timing out

大城市里の小女人 提交于 2019-12-22 06:36:40
问题 Having set up a ReferenceDataRequest I send it along to an EventQueue Service refdata = _session.GetService("//blp/refdata"); Request request = refdata.CreateRequest("ReferenceDataRequest"); // append the appropriate symbol and field data to the request EventQueue eventQueue = new EventQueue(); Guid guid = Guid.NewGuid(); CorrelationID id = new CorrelationID(guid); _session.SendRequest(request, eventQueue, id); long _eventWaitTimeout = 60000; myEvent = eventQueue.NextEvent(_eventWaitTimeout);

Get current instance of Runnable

本小妞迷上赌 提交于 2019-12-13 20:05:45
问题 I'm making an application that allows users to view task lists stored in different databases. So what happens is that, I have a list of the names of browsable databases (stored as a text file). Program loads the first database in that list and displays contents. Then from a menu, I allow users to select another database in the list. (Kind of like, I want to view the tasks for Andy, and now Bob, and now Carl...). Problem is, I don't know how to update the UI so that the contents of the new

Java API “Run on EDT if not on EDT”

血红的双手。 提交于 2019-12-07 10:28:00
问题 Just a musing about some repetitive code I have: Runnable run = new Runnable() { @Override public void run() { // Some EDT code } }; if (!EventQueue.isDispatchThread()) { SwingUtilities.invokeAndWait(run); } else { run.run(); } It's not terribly annoying, but it seems like there would be some proprietary function that checks this for you, although I haven't found it. 回答1: it seems like there would be some proprietary function that checks this for you There isn't. 回答2: Excluding Substance Look

Java API “Run on EDT if not on EDT”

﹥>﹥吖頭↗ 提交于 2019-12-05 14:27:55
Just a musing about some repetitive code I have: Runnable run = new Runnable() { @Override public void run() { // Some EDT code } }; if (!EventQueue.isDispatchThread()) { SwingUtilities.invokeAndWait(run); } else { run.run(); } It's not terribly annoying, but it seems like there would be some proprietary function that checks this for you, although I haven't found it. it seems like there would be some proprietary function that checks this for you There isn't. Excluding Substance Look and Feel I never needed to use invokeAndWait or testing for isDispatchThread / isEventDispatchThread , Substance

EventQueue inconsistent ID's

大憨熊 提交于 2019-12-05 13:44:06
I have a problem with the following example code that shows inconsistent behavior for the EventQueue: public static void main( String[] args ) throws InvocationTargetException, InterruptedException { final long[] id1 = new long[ 1 ]; final long[] id2 = new long[ 1 ]; EventQueue.invokeAndWait( new Runnable() { @Override public void run() { id1[ 0 ] = Thread.currentThread().getId(); } } ); Thread.sleep( 5000 ); EventQueue.invokeAndWait( new Runnable() { @Override public void run() { id2[ 0 ] = Thread.currentThread().getId(); } } ); System.out.println( "id1 = " + id1[0] ); System.out.println(

Is update from EDT in swing an absolute rule or are there exceptions?

耗尽温柔 提交于 2019-12-04 05:02:56
问题 In Swing, the GUI is supposed to be updated by the EDT only, since the GUI components are not thread safe. My question is, if I have a single thread, other than the EDT, that is dedicated to update a specific component, and this component is not accessed by any other thread in my program, only this dedicated thread, is it ok? In my case I have a JTable and a thread receives information from the network and updates the table (without using EventQueue.invokeLater ). All the other components are

java swing clear the event queue

a 夏天 提交于 2019-12-01 18:00:27
问题 Is it possible to do this in a standard manner? Here is the scenario. Start doing something expensive in EDT (EDT is blocked till the expensive operation is over). While EDT was blocked, the user kept on clicking/dragging the mouse buttons. All the mouse actions are recorded somewhere. When EDT is free (done with the expensive stuff), it starts to process the mouse events. What I want in step 3 is to discard the mouse events that have piled up. After the EDT is free, any new mouse event

understanding the node.js event queue and process.nextTick

不打扰是莪最后的温柔 提交于 2019-11-29 02:19:14
I'm having trouble understanding exactly how process.nextTick does its thing. I thought I understood, but I can't seem to replicate how I feel this should work: var handler = function(req, res) { res.writeHead(200, {'Content-type' : 'text/html'}); foo(function() { console.log("bar"); }); console.log("received"); res.end("Hello, world!"); } function foo(callback) { var i = 0; while(i<1000000000) i++; process.nextTick(callback); } require('http').createServer(handler).listen(3000); While foo is looping, I'll send over several requests, assuming that handler will be queued several times behind