Results 1 to 9 of 9
Thread: MultiThreading Problem
- 02-26-2010, 09:29 PM #1
Member
- Join Date
- Jun 2008
- Posts
- 87
- Rep Power
- 0
MultiThreading Problem
I am having a basic problem
I have a class GUi which is showing the GUi of the project
and a class where i process the data
Now when i click on start button the class which process the data is called and when the data being processed at that time GUi frame hangs and buttons get inactive.
Now i know it will be solved by threading so can u help me how to do it .
Eg:
GUI.java
A.javaJava Code:class GUI { ..... void actionListener(...) { new A(); } }
now when A is called the frame in GUI gets inactive but the data processing is performed normally.Java Code:class A { ...... }
Thanks in advance
- 02-27-2010, 01:35 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You can create threads in two ways, using Thread class as well as Runnable interface.
Then start the thread.Java Code:class A extends Thread { public void run() { // Implementation } }
That's very basis of Thread. Read more about in Suns' official website.Java Code:class B { ....... A objA = new A(); objA.start(); }
Lesson: Concurrency (The Java™ Tutorials > Essential Classes)
-
Your problem is that you're calling a long-running process on the EDT, the Event Dispatch Thread, the main thread that Swing uses to do painting and user interaction, and when this happens, Swing simply freezes in its tracts. The solution is to do your background process in a a background thread like a SwingWorker. For details, please look here: Concurrency in Swing
- 02-27-2010, 11:48 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
And also search the forum, Java Tip section as well. You can find lots of similar discussion related to.
- 02-28-2010, 03:59 PM #5
Member
- Join Date
- Jun 2008
- Posts
- 87
- Rep Power
- 0
thank you i have solved it by running the data processing in new thread
thank u
- 03-02-2010, 10:32 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
If you have solved the problem, please mark the thread solved. :)
- 03-02-2010, 10:35 AM #7
Member
- Join Date
- Jun 2008
- Posts
- 87
- Rep Power
- 0
well as per my knowledge the thread is marked solved isnt it?
- 03-02-2010, 10:40 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Oops, I just seen that. Sorry about lol, normally I'm accessing threads from the list, and hard to see it at once. )
- 03-02-2010, 12:23 PM #9
Member
- Join Date
- Jun 2008
- Posts
- 87
- Rep Power
- 0
Similar Threads
-
Log 4j Multithreading
By joe2010 in forum Threads and SynchronizationReplies: 1Last Post: 01-31-2010, 03:48 AM -
problem using ObjectOutputStream in multithreading
By sanjeevbindroo in forum NetworkingReplies: 3Last Post: 10-15-2009, 08:00 AM -
Applet and multithreading
By pricelessjunk in forum Threads and SynchronizationReplies: 1Last Post: 08-03-2009, 09:47 PM -
multithreading
By shilpa.krishna in forum New To JavaReplies: 2Last Post: 06-27-2008, 04:18 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks