Results 1 to 6 of 6
- 01-31-2010, 10:57 AM #1
Member
- Join Date
- Sep 2009
- Posts
- 4
- Rep Power
- 0
Thread concurrency .. What am I missing?
I have spent the better part of the day, albeit fairly diverted on the topic of multithreading and trying to get my threads to work concurrently. They appear to operate in much the same way a normal sequenced program runs.
What am I doing wrong? I am using a runnable interface, normal thread creation, and using sleep timers but my novice level is getting me nowhere.
-
It could be an extra semi-colon on line 42, a call to run() instead of start(), over-use of join(), but for me, then main thing that you're doing wrong is that you're not showing us any of your code. That's about the best most of us can do with the info provided.What am I doing wrong?
- 01-31-2010, 12:57 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,588
- Blog Entries
- 7
- Rep Power
- 17
... and sleeping Threads are also a concurrency killer.
kind regards,
Jos
- 01-31-2010, 07:21 PM #4
Member
- Join Date
- Sep 2009
- Posts
- 4
- Rep Power
- 0
Ok, fair point, not much help I can receive without code. Some background. I am just starting to learn multithreading so tinkering is what I have done since the Java course I am taking this semester is algorithms but always great opportunity to use a project to learn something new.
My implementation is through the Runnable interface and I submit my code here with the sleep() lines removed per the previous suggestion.
Java Code:public interface Runnable { public abstract void run() ; }Java Code:public void run() { int count = 10,enQueueCounter = 1; do { int nextPoisson = linkedList.Poisson(expectedValue); for (int i = 0; i < nextPoisson; i++) { linkedList.enQueue("Manny" + enQueueCounter, 0); // enQueue the node enQueueCounter += 1; count--; } linkedList.setTime(); // set the wait time int temp = linkedList.getTime(); avgWaitTime = temp / enQueueCounter; System.out.println("Average wait time is: " + avgWaitTime + " (s)"); } while(count > 0); System.out.println(enQueueCounter - 1 + " person queued"); linkedList.list(); }Java Code:public void run() { for (seconds = 0; seconds < 5; seconds++) { System.out.println(toString()); } }I may not even be implementing mutilthreading. The threads are running sequentially and here is my problem.Java Code:public static void main(String[] args){ MyList linkedList = new MyList(); Arrivals newArrivals = new Arrivals("Arrivals", 0.5); Server newServer = new Server("Server"); newArrivals.getObject(linkedList); // reference passing newArrivals.run(); newServer.run(); }Last edited by Ebodee; 01-31-2010 at 07:25 PM.
- 01-31-2010, 08:29 PM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,588
- Blog Entries
- 7
- Rep Power
- 17
I don't see any Thread objects in your program code ...
kind regards,
Jos
- 02-01-2010, 07:03 AM #6
Member
- Join Date
- Sep 2009
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
GUI Concurrency Problems
By jkhamler in forum Threads and SynchronizationReplies: 18Last Post: 01-20-2010, 03:40 PM -
IProgessMonitor missing in 3.4?
By aznboarder in forum EclipseReplies: 1Last Post: 03-19-2009, 11:29 PM -
Concurrency system, and threads.
By scarymovie in forum New To JavaReplies: 2Last Post: 03-05-2009, 02:20 AM -
concurrency question
By diggitydoggz in forum New To JavaReplies: 4Last Post: 01-17-2009, 03:48 AM -
Explanation bout threading and concurrency?
By cruxblack in forum New To JavaReplies: 1Last Post: 08-10-2007, 10:33 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks