Results 1 to 4 of 4
  1. #1
    Jack_Tauson_Sr is offline Senior Member
    Join Date
    Nov 2011
    Posts
    114
    Rep Power
    0

    Default Question about Multithreading !

    Suppose I am running 10 threads to grab a data(1000) from a database table located at one
    IP Address and Insert it into another database located at different IP address.So how does this
    multithreading decide the number of records each thread will carry out of 1000 records in the database?

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,786
    Rep Power
    5

    Default Re: Question about Multithreading !

    That is pretty much up to you. Threads are just programs that run concurrently. So you need to instruct each thread how and when to do network I/O to and from a database. There's no point in each thread reading the same records because it's inefficient. And I presume writing them concurrently to a DB could cause problems but I guess that depends on the DB. You need to sync their behavior so they don't clobber each other. And you also have to decide how many threads, if any, will improve the overall performance of the system, since that is usually the overall goal.

    Caveat: I am a retired network engineer with a degree in CS who has minimal experience with data base management.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Jack_Tauson_Sr is offline Senior Member
    Join Date
    Nov 2011
    Posts
    114
    Rep Power
    0

    Default Re: Question about Multithreading !

    Thanks for your answer. By any chance you know how to decide the number of threads I should use for best performance?

    Also, is there a way in Netbeans to check the performance of my application based on the number of threads I use?
    Quote Originally Posted by jim829 View Post
    That is pretty much up to you. Threads are just programs that run concurrently. So you need to instruct each thread how and when to do network I/O to and from a database. There's no point in each thread reading the same records because it's inefficient. And I presume writing them concurrently to a DB could cause problems but I guess that depends on the DB. You need to sync their behavior so they don't clobber each other. And you also have to decide how many threads, if any, will improve the overall performance of the system, since that is usually the overall goal.

    Caveat: I am a retired network engineer with a degree in CS who has minimal experience with data base management.

    Regards,
    Jim

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,786
    Rep Power
    5

    Default Re: Question about Multithreading !

    I really don't know. I can assume it depends on a lot of factors. How many concurrent writes can you do? What's the B/W of the network path? It's sort of like if you can't completely empty one bucket before a second is full, then you only need two buckets. That's a very simplified analogy so others in this forum may offer some better guidance. And as far as profiling on Netbeans, I don't use that IDE.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Multithreading question about thread safety
    By javajp in forum Threads and Synchronization
    Replies: 0
    Last Post: 02-13-2013, 11:01 PM
  2. Multithreading question
    By booboo0187 in forum Threads and Synchronization
    Replies: 2
    Last Post: 01-31-2013, 08:55 PM
  3. Want to know about Multithreading.
    By Chetans in forum Threads and Synchronization
    Replies: 1
    Last Post: 03-19-2010, 07:50 AM
  4. Log 4j Multithreading
    By joe2010 in forum Threads and Synchronization
    Replies: 1
    Last Post: 01-31-2010, 03:48 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
  •