Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By DarrylBurke

Thread: NetBeans thread changes reverting to initial values

  1. #1
    iamihop is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default NetBeans thread changes reverting to initial values

    I don't know if anyone will be able to answer this question, because it is impractical to present the actual code; it is very long, complex, and not well annotated.

    I am using NetBeans to develop a basic application that will include a certain amount of thread-based animation. The trouble I am having is that the animation works at first, but at seemingly random intervals, all variables that were changed during the threads' execution revert back to their initial states. I've been wrestling with this thing for a long time, and actually gave up on it for a year.

    Can anyone give me some ideas why changes made in a thread would be overridden by the original values? Do I have to do something to make the changes permanent? Is this some quirk of the NetBeans application platform? It is NOT my code that is causing the changed values to revert, as far as I can tell.

    Thanks!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: NetBeans thread changes reverting to initial values

    I think you're right, no one will be able to tell you why your code has quirky bugs in it without seeing the code. I think that your task is to do some aggressive debugging before you're even at a stage where you can ask for and receive help. Sprinkle your code with println statements to check the state of key fields, and isolate your error(s).

    Oh, and I can almost guarantee 99.999% sure, that it is your code that is causing the problem. I will bet that the coders who created NetBeans are far better coders than you or I, and the odds of them making a mistake vs. you making a mistake are astronomically small.

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: NetBeans thread changes reverting to initial values

    And you can compile and run the program *without* using Netbeans to gain further information.

  4. #4
    iamihop is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default Re: NetBeans thread changes reverting to initial values

    Thanks for the reply.

    Trust me, the code is littered with printlns. I have scoured it for problems for hours and hours (and years, in fact). I've actually implemented the threading in several different ways - using Runnable implementation, Thread extension, and built-in Swing Timers, and the problem recurs sporadically with each.

    The reason I don't think it's my code that is doing the overwriting is that I have removed all of my code that changes the locations and variables, outside of the animation thread itself. I definitely don't think that NetBeans is doing something wrong - they're a million times the programmer I am, for sure. I just think I'm doing something wrong, or leaving something out, so the NetBeans code is reverting the variables.

    I like NetBeans for all of its automatic code, especially for GUIs, but it can be hard to see what's going on behind the curtains.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: NetBeans thread changes reverting to initial values

    But again variables don't magically revert. Keep attempting to isolate, either that or try to re-code your program.

    Questions:
    • Do you have good separation of concerns?
    • Do you use an MVC design pattern or one of its many variants?
    • Are you able to test each unit of your code in isolation?
    • Are you using unit testing or other testing frameworks?


    Best of luck!

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,196
    Rep Power
    19

    Default Re: NetBeans thread changes reverting to initial values

    • Are you calling Swing methods off of the EDT?


    db
    Fubarable likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. How to substract each value from the initial value.
    By whateverme in forum New To Java
    Replies: 8
    Last Post: 10-27-2010, 02:26 PM
  2. tricky initial value problem
    By Black_Eye in forum New To Java
    Replies: 4
    Last Post: 10-19-2010, 09:02 AM
  3. Initial capacity of ArrayList
    By bugger in forum New To Java
    Replies: 12
    Last Post: 12-30-2009, 08:16 AM
  4. How to set the designer initial properties when making web report
    By freezea in forum Reviews / Advertising
    Replies: 0
    Last Post: 06-04-2009, 04:25 PM
  5. Replies: 1
    Last Post: 08-13-2007, 03:46 AM

Posting Permissions

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