Page 4 of 4 FirstFirst ... 234
Results 61 to 68 of 68

Thread: Threads!!!

  1. #61
    smartino is offline Member
    Join Date
    Sep 2011
    Posts
    64
    Rep Power
    0

    Default Re: Threads!!!

    Ok if you say so, but can you verify that if I run down this road with printlin's that it will work.

    My question is, based on the code I sent you, were you able to get this to work and find the actual problem, or my code will never work without major overhaul?

  2. #62
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: Threads!!!

    No, I can't guarantee that your code will work. I'm not sure exactly what you want it to do. I have not looked at any of your usages of Threads and synchronization. There were too many other bugs that needed solving first.
    I've asked you several questions about your code as leads for you to look at why the code was doing what I observed and you have ignored them. Go back through my posts and make sure you know what is happening in your code in relation to the questions I asked.

    Reread post#60.

  3. #63
    smartino is offline Member
    Join Date
    Sep 2011
    Posts
    64
    Rep Power
    0

    Default Re: Threads!!!

    My apologies, I thought I had answered all of your questions, and have put println's in every place I can imagine. I looked at post #60, but that did not have questions, it was a recent post today, based on me going through the threads of this discussion.

    Again, my apologies, I am doing the best I can.

    Thanks for trying to help me.

  4. #64
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: Threads!!!

    Look at posts 48, 50, 52, 55 and 57

  5. #65
    smartino is offline Member
    Join Date
    Sep 2011
    Posts
    64
    Rep Power
    0

    Default Re: Threads!!!

    From Number 48....

    Perhaps you should simplify the testing to see if each of the steps the Client does works.
    For example do only a balance enquiry.
    The do a balance enquiry and a deposit and a balance enquiry.

    How have instances of the Account class is the program supposed to create?



    First Question or Statement above:

    I will limit it to just a BALANCE and see if I can track this down, I would assume the goal is to not make the Server.java program HANG and complete normally, something that I have not been able to do...

    Second Questions:

    I believe that the Account class should only have 1 instance, since we have a single Account and one person making DEPOSIT and WITHDRAWALS.

    I don't know of a way to verify that is happening, any insight would be helpful on how to check that?

  6. #66
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: Threads!!!

    I don't know of a way to verify that is happening,
    Add some println statements.
    Look at my printout from when I executed the program. Look for this: "new Account created"
    Count how many times that is printed out.

    Exiting main
    new Account created
    ATMImp bal=10000.0, this=ClientServer6$ATMImplementation@1a758cb
    new Account created
    ATMImp bal=10000.0, this=ClientServer6$ATMImplementation@69b332
    S - Accepting clients now
    S - Client acquired on port #7777, reading from socket
    ATMProxy writing command to server: BALANCE
    new Account created
    ATMImp bal=10000.0, this=ClientServer6$ATMImplementation@1270b73
    S - requestQueue Size is: 1
    S - commandLine equals: BALANCE
    ATMR - requestQueue Size is: 1
    ATMR - requestQueue Size is: 1
    ATMR - I am returning atmRunnableItem=ATMRn cmdLine=BALANCE
    ATMR run - Threads should go here eventually... cL=BALANCE
    ATMImpl BALANCE=10000.0
    ATMR run println result=10000.0
    ATMProxy: Server returned: 10000.0
    C1 - Balance: 10000.0
    C2 - Depositing: 1000 DDD0
    ATMProxy writing command to server: DEPOSIT
    new Account created
    ATMProxy writing command to server: BALANCE
    ATMImp bal=10000.0, this=ClientServer6$ATMImplementation@16caf43 <<<<<<<<<<<<<
    S - requestQueue Size is: 1
    S - commandLine equals: DEPOSIT 1000.0
    ATMR - requestQueue Size is: 1
    ATMR - requestQueue Size is: 1
    ATMR - I am returning atmRunnableItem=ATMRn cmdLine=DEPOSIT 1000.0 DDD1
    new Account created
    ATMImp bal=10000.0, this=ClientServer6$ATMImplementation@8813f2 <<<<<<<<<<<<<
    S - requestQueue Size is: 1
    S - commandLine equals: BALANCE
    ATMR - requestQueue Size is: 1
    ATMR - requestQueue Size is: 1
    ATMR - I am returning atmRunnableItem=ATMRn cmdLine=BALANCE
    ATMR run - Threads should go here eventually... cL=DEPOSIT 1000.0
    ATMImpl making a DEPOSIT amt=1000.0, new balance=11000.0 DDD2
    ATMR run - Threads should go here eventually... cL=BALANCE
    ATMImpl BALANCE=11000.0
    ATMR run println result=11000.0
    ATMProxy: Server returned: 11000.0 DDD3
    C3 - Balance: 11000.0

    WWW0
    C4 - Withdrawing: 250
    ATMProxy writing command to server: WITHDRAW
    new Account created
    ATMProxy writing command to server: BALANCE
    ATMImp bal=10000.0, this=ClientServer6$ATMImplementation@83cc67 <<<<<<<<<<<<<
    S - requestQueue Size is: 1
    S - commandLine equals: WITHDRAW 250.0 WWW1
    ATMR - requestQueue Size is: 1
    ATMR - requestQueue Size is: 1
    ATMR - I am returning atmRunnableItem=ATMRn cmdLine=WITHDRAW 250.0
    new Account created
    ATMR run - Threads should go here eventually... cL=WITHDRAW 250.0
    ATMImp bal=10000.0, this=ClientServer6$ATMImplementation@de6f34 <<<<<<<<<<<<<
    S - requestQueue Size is: 1
    S - commandLine equals: BALANCE
    ATMR - requestQueue Size is: 1
    ATMImpl making a WITHDRAWAL amt=250.0, new balance=10750.0 WWW2
    ATMR - requestQueue Size is: 1
    ATMR - I am returning atmRunnableItem=ATMRn cmdLine=BALANCE
    ATMR run - Threads should go here eventually... cL=BALANCE
    ATMImpl BALANCE=10750.0
    ATMR run println result=10750.0
    ATMProxy: Server returned: 10750.0 WWW3
    C5 - Balance: 10750.0


    C6 - Withdrawing: 750
    ATMProxy writing command to server: WITHDRAW
    new Account created
    ATMProxy writing command to server: BALANCE
    ATMImp bal=10000.0, this=ClientServer6$ATMImplementation@47b480 <<<<<<<<<<<<<
    S - requestQueue Size is: 1
    S - commandLine equals: WITHDRAW 750.0
    ATMR - requestQueue Size is: 1
    ATMR - requestQueue Size is: 1
    ATMR - I am returning atmRunnableItem=ATMRn cmdLine=WITHDRAW 750.0
    new Account created
    ATMR run - Threads should go here eventually... cL=WITHDRAW 750.0
    ATMImp bal=10000.0, this=ClientServer6$ATMImplementation@10d448
    S - requestQueue Size is: 1
    S - commandLine equals: BALANCE
    ATMR - requestQueue Size is: 1
    ATMImpl making a WITHDRAWAL amt=750.0, new balance=10000.0
    ATMR - requestQueue Size is: 1
    ATMR - I am returning atmRunnableItem=ATMRn cmdLine=BALANCE
    ATMR run - Threads should go here eventually... cL=BALANCE
    ATMImpl BALANCE=10000.0
    ATMR run println result=10000.0
    ATMProxy: Server returned: 10000.0
    C7 - Balance: 10000.0
    ATMProxy: Sending End program
    S - End program
    2Back from Client.main() call
    S - Client serviced
    S exiting main

    0 error(s)

  7. #67
    smartino is offline Member
    Join Date
    Sep 2011
    Posts
    64
    Rep Power
    0

    Default Re: Threads!!!

    Ok, I count 9 in your printout, I just put a println in ATMImplementation and counted 5 from just doing a single Balance command, which obviously is to many, i only need 1....

    This is getting called each time I run a COMMAND, since it calls ATM which ATMImplementation.java implements...

    Not sure how to get around this.

  8. #68
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: Threads!!!

    Not sure how to get around this.
    You need to go back to the design phase and figure out when and where to create an account.
    Perhaps add a new Command to create an account.

Page 4 of 4 FirstFirst ... 234

Similar Threads

  1. Threads
    By nsr2008.mca in forum New To Java
    Replies: 7
    Last Post: 10-18-2010, 11:47 AM
  2. Threads and UML
    By JUser in forum Advanced Java
    Replies: 0
    Last Post: 09-27-2010, 08:43 PM
  3. Threads
    By Tanuck in forum New To Java
    Replies: 5
    Last Post: 09-21-2010, 02:44 AM
  4. When to use threads
    By simorgh in forum Threads and Synchronization
    Replies: 2
    Last Post: 02-12-2010, 07:43 AM
  5. Threads
    By one198 in forum Threads and Synchronization
    Replies: 1
    Last Post: 11-20-2007, 06:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •