Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Single Server Queue Problem

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Single Server Queue Problem

    *Requested to be deleted.
    Last edited by Chassy13; March 19th, 2014 at 09:40 PM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Single Server Queue Problem

    How do you execute the code for testing? I don't see a main() method.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Single Server Queue Problem

    The code hangs when I start its execution? There is no output.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Single Server Queue Problem

    Here's what I get with that input:
    Running: java.exe -cp . SingleServerQueueTest

    Time updated by 2 time units and time is now 2.
    No customer is being served at the present time of 2.
    A customer entered system at time 2. Number waiting in queue is 0.
    Time updated by 4 time units and time is now 6.
    A customer entered system at time 6. Number waiting in queue is 1.
    Time updated by 1 time unit and time is now 7.
    A customer entered system at time 7. Number waiting in queue is 2.
    Customer C1/T2 finished at time 7. Number waiting is 2.
    Program Error!

    1 error(s)
    Here is the statement I use to automate input:
          stdin = new Scanner("T 2\nC\nA\nT 4\nA\nT 1\nA\nC\n"); //<<<<<<<<<<System.in);

    Why is the last line wrong?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Single Server Queue Problem

    Did the output from my version look like what you get?

    Do the values in the Scanner class's constructor I posted work for you and give you the output showing the problem?

    Why is the last line wrong?
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Single Server Queue Problem

    For testing you should put a String in the Scanner class's constructor like I showed earlier so everyone that tries testing will easily get the same results. I find typing in responses prone to error besides being a waste of time.

    You need to add some debug output to show the status of the queue as the code executes to see what is happening.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Problem with actionlistener/drop-down-menu (for a queue)
    By blueroselara in forum AWT / Java Swing
    Replies: 17
    Last Post: January 25th, 2012, 11:59 PM
  2. Java SERVER problem
    By Rex the king in forum Web Frameworks
    Replies: 2
    Last Post: November 16th, 2011, 09:22 AM
  3. problem with uploading an image to server
    By jzarapsa in forum Java Servlet
    Replies: 3
    Last Post: October 17th, 2011, 09:29 PM
  4. Replies: 3
    Last Post: April 11th, 2011, 09:51 PM
  5. client server program on a single machine
    By subhopam in forum Java Networking
    Replies: 1
    Last Post: December 16th, 2009, 02:02 PM