|
-
December 18th, 2012, 01:03 AM
#1
Does SwingUtilities.invokeLater() keep order with threads?
Hi there,
I think I have a threading issue but it all depends on how invokeLater() works. From my understanding invokeLater() will place each thread on a queue and be handled. The question is does it handle it in order? For example, if I put thread1 on the queue first, does it gaturnetee thread1 will be served up first, or could thread2 be called before thread1?
Code:
public static void main(String args[]) {
System.out.println("BEFORE RUN");
SwingUtilities.invokeLater(
new Runnable()
{
@Override
public void run() {
try {
System.out.println("SLEEPING...");
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("TEST1");
}
});
SwingUtilities.invokeLater(
new Runnable()
{
@Override
public void run() {
System.out.println("TEST2");
}
});
}
I keeping getting the same output:
BEFORE RUN
SLEEPING...
TEST1
TEST2
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|