This is a really simple question about the invokeAndWait thing from swing utilities. I have heard that it synchronizes code execution on a single thread, but I'm not sure. If so, should I use invokeAndWait to do that?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
SwingUtilities.invokeAndWait(Runnable)
will enqueue theRunnable
on the Event Queue. This will allow the Event Dispatching Thread to execute therun
method of theRunnable
within the context of the Event Dispatching Thread.invokeAndWait
will not return until AFTER the EDT has finished executing therun
method. This means it's a blocking operation.invokeAndWait
is used to re-sync code to the EDT, allowing it to execute updates to the UI within the Swing toolkit.Unless you are trying to get you code to be executed on the EDT, no, you shouldn't use it for thread synchronization.