Results 1 to 7 of 7
- 01-20-2009, 08:17 AM #1
Member
- Join Date
- Jan 2009
- Posts
- 14
- Rep Power
- 0
How to stop thread from being jumping off the code without executing it.....
Hi friends,
This is chirag kini, I am working on Live project of Online Lottery System. (Client - Server architecture). My problem is, whenever i try to call a methods from running thread, says:
function1();
function2(); (in my run() method)
sometimes it executes both functions perfectly, and sometimes it simply skips off function2();
Even sometimes function2() gets called, it doesnot repaint the Application with the changes done in function2().
Which results in instability in application in client side.
I am talking about the client side threads.....
SO please guys, if anyone knows how to tackle this..... pleaaaaaaaaaaaaase
help me out...
waiting for all....
Thanks in Advance.....
- 01-21-2009, 06:34 AM #2
its is what thread means....
in thread , nothing is guaranteed.......
try using synchronized methods...
instead of thread its will be best if u maintain session if its a web application.
- 01-21-2009, 07:05 AM #3
javamex.com
check this
- 01-21-2009, 09:00 AM #4
Member
- Join Date
- Jan 2009
- Posts
- 14
- Rep Power
- 0
thanxxxx dude....
My application is client server architecture where my client is swing application. In my application i need to execute some threads which are requesting the server database for any changes in table values........
- 01-21-2009, 10:16 AM #5
do u mean
Swing threading and the event-dispatch thread...?
- 01-21-2009, 04:13 PM #6
Sounds like your problem is not with your thread but with the fact that your thread is attempting to update Swing components. That can certainly lead to unpredictable results.
The problem is that Swing runs in its own thread, called the EDT. Your thread may well have made "local copies" of the components you update, so the EDT never sees the updates.
The EventQueue class is the basic means to accessing the EDT. Try code like this:
EventQueue.invokeLater() allows you to run code on the EDT. The EventQueue class is responsible for making sure everything runs in order.Java Code:final String finalValue1 = value1; final int finalValue2 = value2; EventQueue.invokeLater(new Runnable() { public void run() { component1.setText(finalValue1); component2.setValue(finalValue2); } });
The reason for the two "final" variables is that only final local variables are visible from inside an anonymous inner class. That's a bit annoying, but it's no big deal.
- 01-22-2009, 03:38 AM #7
Member
- Join Date
- Jan 2009
- Posts
- 14
- Rep Power
- 0
Similar Threads
-
Can you stop a gif? xd
By Exhonour in forum New To JavaReplies: 0Last Post: 01-16-2009, 08:44 PM -
how to stop a thread
By willemjav in forum Advanced JavaReplies: 19Last Post: 09-10-2008, 07:11 AM -
The safe way to stop a thread
By Java Tip in forum java.langReplies: 0Last Post: 04-09-2008, 06:31 PM -
Eclipse - jumping to method definition
By Java Tip in forum Java TipReplies: 0Last Post: 11-07-2007, 02:52 PM -
Executing Ant code pragramatically
By MikeO in forum Advanced JavaReplies: 0Last Post: 07-24-2007, 09:34 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks