Results 1 to 6 of 6
Thread: Threading in Java
- 11-14-2011, 09:37 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 4
- Rep Power
- 0
- 11-14-2011, 11:32 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,619
- Rep Power
- 5
Re: Threading in Java
You've provided little information. For instance, we don't know how you are creating and starting the threads.
Runnable is an interface, not a class. Again no information, but based upon the above sentence my .02: do not use inheritance - implement Runnable and pass this to a Thread object.using inheritance of Thread class and runnable class.
- 11-15-2011, 03:36 PM #3
Member
- Join Date
- Nov 2011
- Posts
- 4
- Rep Power
- 0
Re: Threading in Java
I just love how people pick up the insignificant details. Typical computer scientist.
My class implements runnable so it have run() method.
I then create thread using the runnable interface.
I have seen that IO can be an issue.
But I am only outputing with system.out.println.
Not sure if that have any effect.
Let me know if there are any other potential factors, otherwise my code looks similar the below.
class BasicThread2 implements Runnable {
// This method is called when the thread runs
public void run() {
}
}
// Create the object with the run() method
Runnable runnable = new BasicThread2();
// Create the thread supplying it with the runnable object
Thread thread = new Thread(runnable);
// Start the thread
thread.start();
- 11-15-2011, 04:02 PM #4
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,619
- Rep Power
- 5
Re: Threading in Java
And I just love how people disregard advice as insignificant...means that's one less post I will spend my time answering.
Originally Posted by kfcni
- 11-15-2011, 04:09 PM #5
Member
- Join Date
- Nov 2011
- Posts
- 4
- Rep Power
- 0
Re: Threading in Java
Somebody on another forum just relied that XP, the OS I am using, does not allocate more than one CPU for a process.
That is stupid.............
Any workaround?
- 11-15-2011, 05:34 PM #6
Similar Threads
-
Java Mem and threading tips
By masijade in forum Reviews / AdvertisingReplies: 2Last Post: 06-16-2011, 04:30 PM -
Getting problem in threading in JAVA
By Chetans in forum Threads and SynchronizationReplies: 3Last Post: 03-19-2010, 07:49 AM -
Java threading
By Eranga in forum Advanced JavaReplies: 2Last Post: 03-13-2008, 05:30 AM -
question about Multi threading in Java
By fred in forum Advanced JavaReplies: 1Last Post: 07-24-2007, 01:55 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks