Results 1 to 6 of 6
Thread: Java Threads
- 05-06-2011, 02:50 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 23
- Rep Power
- 0
Java Threads
Hi,
I have a user input class that reads the user input values (From UI) and another class that computes some complex calculations using these values. I want the computation class to be independent of the user input class. Can this computation class be implemented as a thread to serve my purpose?? Can anyone help me??
- 05-06-2011, 03:04 PM #2
Assuming that's a Swing GUI (which you didn't tell us), check out this tutorial:
Lesson: Concurrency in Swing (The Java™ Tutorials > Creating a GUI With JFC/Swing)
Particularly the section on SwingWorker.
db
- 05-06-2011, 09:00 PM #3
Senior Member
- Join Date
- Mar 2011
- Posts
- 261
- Rep Power
- 3
Yes, and Darryl is right with the SwingWorker, but you can just create a regular Thread (read up on threads).
-
- 05-09-2011, 06:22 AM #5
Member
- Join Date
- Mar 2011
- Posts
- 23
- Rep Power
- 0
Hi,
I read the tutorial and implemented it. Now I am facing another problem.
I have another example where I have three different stages. First stage is a GUI(Swing). When I click a button from the GUI, I perform an action. When I reach a certain point during that action(say action-1), I need to start another action(say action-2). While I need to run only a single instance of action-1 and it is a dependent process, I want to run the multiple instances of action-2 and they are independent processes. I want to create atleast a thousand instances of action-2 at a moment (my main purpose is to give each user a thread of action-2 and I am considering 1000 users. ) Is this possible??
- 05-09-2011, 07:40 AM #6
Member
- Join Date
- Mar 2011
- Posts
- 23
- Rep Power
- 0
Hi,
Let me add my code snippets here so that it will be more clear to u..
public class getvalues()
{
...
....
...
if(key == name)
userTest utest = new userTest();
new Thread(utest).start();
...
....
....
.....
}
and I have a userTest class implementing runnable interface
class userTest implements Runnable {
public void run() {
System.out.println("Entered Thread ");
....
....
...
}
Here, my requirement is that class "a" should not depend on thread userTest. Even if the userTest is being blocked due to some reason, class a should continue its execution. Here, with respect to my implementation, class a waits until the execution of userTest is finished executing. Can any one help me plz...
Similar Threads
-
Java threads
By naik_amit in forum Threads and SynchronizationReplies: 1Last Post: 08-25-2010, 11:21 PM -
Threads in Java
By ZeCute in forum New To JavaReplies: 2Last Post: 05-20-2010, 04:06 PM -
How to use Java threads
By Java Tip in forum java.langReplies: 0Last Post: 04-09-2008, 06:30 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks