Results 1 to 5 of 5

Thread: how fast?

  1. #1
    Join Date
    Apr 2010
    Posts
    20
    Rep Power
    0

    Default how fast?

    I have a java code that is receiving ethernet packets and writing into a file in decimal format.

    Each packet consist of 1000 bytes and the delay between packets is 100 micro seconds.

    When i noticed carefully , lots of packets are missing!...can java receive and store in a text file with high speed? if not, what is the maximum limit?

    Would really appreciate if someone can help.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,337
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by abdullahansari View Post
    I have a java code that is receiving ethernet packets and writing into a file in decimal format.

    Each packet consist of 1000 bytes and the delay between packets is 100 micro seconds.

    When i noticed carefully , lots of packets are missing!...can java receive and store in a text file with high speed? if not, what is the maximum limit?

    Would really appreciate if someone can help.
    Use two threads: one to receive the data store it in memory and another thread that writes the collected data to a file. That scenaria makes the in memory collection a critical resource, the first thread will be the 'producer' and the file writing thread will be the 'consumer'.

    You have to synchronize on that critical resource, i.e. if it is being emptied by the consumer the producer has to wait before it can store new information (the new incoming packet) in it and the consumer has to wait until something is available for writing.

    kind regards,

    Jos

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

    Default

    if it is being emptied by the consumer the producer has to wait before it can store new information
    Or have a list/queue to put the new info in so that the producer never has to wait.
    Then add some code to keep track of the queue length to see if the producer ever gets ahead of the consumer.

  4. #4
    Join Date
    Apr 2010
    Posts
    20
    Rep Power
    0

    Default passing data between threads

    Thank you for your suggestions.
    I m very new to java especially concurrent programming.
    How do i pass the data from one thread to another?
    My imaginary plan is to create an array and store the data in one thread and
    open a file ,write the data and close the file in the other thread.
    But my questions is how do i transfer the array from one thread to another?
    Do i need an action listener ?
    ..

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

    Default

    You don't pass the data. The producer thread saves it in a container and the consumer thread gets it from that container.
    You'll need to look at the Tutorial and other docs to understand the process and which java classes to use to do this.
    You can't do any design work on this until understand the process.

Similar Threads

  1. Extremely fast applet
    By FerretSpy440 in forum Java Applets
    Replies: 0
    Last Post: 07-17-2009, 04:12 AM
  2. Help me fast!
    By Manikyr in forum New To Java
    Replies: 4
    Last Post: 03-16-2009, 07:43 AM
  3. HELP FAST!!----Interest Calculator
    By Coop33 in forum New To Java
    Replies: 8
    Last Post: 10-15-2008, 01:44 PM
  4. pls help me fast!
    By rexson98 in forum New To Java
    Replies: 10
    Last Post: 10-15-2008, 12:20 PM
  5. Fast Data Transfer 0.6.4
    By levent in forum Java Software
    Replies: 0
    Last Post: 05-20-2007, 08:55 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
  •