-
Bug
-
Resolution: Fixed
-
P3
-
7, 8, 9
-
b68
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8098689 | emb-9 | Semyon Sadetsky | P3 | Resolved | Fixed | team |
JDK-8183823 | 8u161 | Semyon Sadetsky | P3 | Resolved | Fixed | b01 |
JDK-8175181 | 8u152 | Semyon Sadetsky | P3 | Resolved | Fixed | b02 |
JDK-8192558 | emb-8u161 | Semyon Sadetsky | P3 | Resolved | Fixed | b01 |
Here is a code snippet from java.awt.SecondaryLoop JavaDoc:
SecondaryLoop loop;
JButton jButton = new JButton("Button");
jButton.addActionListener(new ActionListener() {
{@code @Override}
public void actionPerformed(ActionEvent e) {
Toolkit tk = Toolkit.getDefaultToolkit();
EventQueue eq = tk.getSystemEventQueue();
loop = eq.createSecondaryLoop();
// Spawn a new thread to do the work
Thread worker = new WorkerThread();
* worker.start();
// Enter the loop to block the current event
// handler, but leave UI responsive
** if (!loop.enter()) {
// Report an error
}
}
});
class WorkerThread extends Thread {
{@code @Override}
public void run() {
// Perform calculations
doSomethingUseful();
// Exit the loop
*** loop.exit();
}
}
The code marked with (*) spawns a new thread. Note that (***), which is called on this new thread, can potentially be invoked before the loop is started with (**). This is not a problem in java.awt.Secondary loop, however there's no easy way for developers to detect and resolve this situation.
SecondaryLoop loop;
JButton jButton = new JButton("Button");
jButton.addActionListener(new ActionListener() {
{@code @Override}
public void actionPerformed(ActionEvent e) {
Toolkit tk = Toolkit.getDefaultToolkit();
EventQueue eq = tk.getSystemEventQueue();
loop = eq.createSecondaryLoop();
// Spawn a new thread to do the work
Thread worker = new WorkerThread();
* worker.start();
// Enter the loop to block the current event
// handler, but leave UI responsive
** if (!loop.enter()) {
// Report an error
}
}
});
class WorkerThread extends Thread {
{@code @Override}
public void run() {
// Perform calculations
doSomethingUseful();
// Exit the loop
*** loop.exit();
}
}
The code marked with (*) spawns a new thread. Note that (***), which is called on this new thread, can potentially be invoked before the loop is started with (**). This is not a problem in java.awt.Secondary loop, however there's no easy way for developers to detect and resolve this situation.
- backported by
-
JDK-8098689 Make tracking SecondaryLoop.enter/exit methods easier
-
- Resolved
-
-
JDK-8175181 Make tracking SecondaryLoop.enter/exit methods easier
-
- Resolved
-
-
JDK-8183823 Make tracking SecondaryLoop.enter/exit methods easier
-
- Resolved
-
-
JDK-8192558 Make tracking SecondaryLoop.enter/exit methods easier
-
- Resolved
-
- relates to
-
JDK-8131670 [TEST_BUG]Test java/awt/EventQueue/6980209/bug6980209.java fails on Linux
-
- Resolved
-
-
JDK-6949936 Provide API for running nested events loops, similar to what modal dialogs do
-
- Closed
-
(1 relates to)