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 2 of 2

Thread: Remove from array after a period of time

  1. #1
    Junior Member
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Remove from array after a period of time

    I'm having trouble with people flooding my java app with connections, and right now I have it so that if an IP opens more then 2 connections at once with it, it adds it to a "bad connections" array and disallows that ip from connecting.

    But.. I'm having trouble thinking of how I would go about making it so that after the IP has been in the bad connections array for a minute, it removes it from the array.


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Remove from array after a period of time

    First of all I guess you would have to store the ip and the time it was added to the list. Have some sort of timed job running that loops through the list every so often and clears out and ip that was added more than 1 minute ago. This could possibly be done implementing Runnable or by a TimerTask of some sort.

    // Json

Similar Threads

  1. [SOLVED] how to get phone time and date
    By mahdi in forum Java ME (Mobile Edition)
    Replies: 2
    Last Post: August 26th, 2009, 11:15 AM
  2. SQL Time Calculation
    By r12ki in forum JDBC & Databases
    Replies: 3
    Last Post: July 31st, 2009, 03:54 AM
  3. Changing colors of large image in real time
    By chals in forum Java ME (Mobile Edition)
    Replies: 1
    Last Post: May 7th, 2009, 05:06 AM
  4. How to Get the current date and time
    By JavaPF in forum Java Programming Tutorials
    Replies: 2
    Last Post: December 2nd, 2008, 12:55 PM