Results 1 to 16 of 16

Thread: multithreading

  1. #1
    Join Date
    Feb 2011
    Posts
    11
    Rep Power
    0

    Default multithreading

    As we know that quad core processor has four processors, so keeping that in mind I need a program in java wherein we can use the concept of running multiple threads simultaneously in four different processor...In this case four different threads in four different processor....I somewhere read that to implement this we need to utilise 100%of each processor...please help me out as it is necessary for my project...any kind of help is most welcome....

  2. #2
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default

    Well you nothing explain about your project.
    What do you want create?
    Skype: petrarsentev
    http://TrackStudio.com

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

    Default

    If you need specific control over threading to be sure that the threads run on separate processors, then perhaps you shouldn't use Java but should use a programming language that will allow you to get closer to the hardware such as C/C++ or asm.

  4. #4
    Bellerofonte is offline Member
    Join Date
    Feb 2011
    Location
    Rome, IT
    Posts
    4
    Rep Power
    0

    Default

    you have to keep on mind that in a real system probably there are much more processes than four; this mean that in any case you ( all ) have a simulated parallelism, know as concurrency and not a real parallelism. What i mean?! Parallelism : each processes have one CPU. Concurrency : One CPU for all processes that through OS scheduling policy simulate parallelism.

    So, you can modify scheduling policy and then create a parallel program with four processes, each with its threads. In any case your program never be parallel because you must divide your CPU with S.O. Runtime Support.

  5. #5
    Join Date
    Feb 2011
    Posts
    11
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    If you need specific control over threading to be sure that the threads run on separate processors, then perhaps you shouldn't use Java but should use a programming language that will allow you to get closer to the hardware such as C/C++ or asm.
    Quote Originally Posted by Petr View Post
    Well you nothing explain about your project.
    What do you want create?
    well my project is on pattern matching...in which you search for a particular pattern in a given text......consider an example where we are looking for particular DNA sequence in some DNA repository....so what i am trying to do is I will divide the given text into two halves and then i will search the pattern from both sides that is from left to right and right to left on both the halves simultaneously..and will display the total matches found...and position where each pattern is found in a given text...and sometimes it does happens that a pattern can be found at the junction where we are dividing..so for that there is a special case where we are taking the substring....and i want to implement this thing with the help of multithreading...where i can create four threads for each of those loops and run them simultaneously on different processors.......actually this idea was given by my professor........and he wants me to do that......there are various algorithms which implement pattren matching such as brute force,rabin karp etc. but they do in a single direction......

  6. #6
    Join Date
    Feb 2011
    Posts
    11
    Rep Power
    0

    Default multithreading

    Quote Originally Posted by Petr View Post
    Well you nothing explain about your project.
    What do you want create?
    well my project is on pattern matching...in which you search for a particular pattern in a given text......consider an example where we are looking for particular DNA sequence in some DNA repository....so what i am trying to do is I will divide the given text into two halves and then i will search the pattern from both sides that is from left to right and right to left on both the halves simultaneously..and will display the total matches found...and position where each pattern is found in a given text...and sometimes it does happens that a pattern can be found at the junction where we are dividing..so for that there is a special case where we are taking the substring....and i want to implement this thing with the help of multithreading...where i can create four threads for each of those loops and run them simultaneously on different processors.......actually this idea was given by my professor........and he wants me to do that......there are various algorithms which implement pattren matching such as brute force,rabin karp etc. but they do in a single direction......

  7. #7
    Join Date
    Feb 2011
    Posts
    11
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    If you need specific control over threading to be sure that the threads run on separate processors, then perhaps you shouldn't use Java but should use a programming language that will allow you to get closer to the hardware such as C/C++ or asm.
    cant we do that thing in java....i think java is far more better than c and c++....

  8. #8
    Join Date
    Feb 2011
    Posts
    11
    Rep Power
    0

    Default

    Quote Originally Posted by Bellerofonte View Post
    you have to keep on mind that in a real system probably there are much more processes than four; this mean that in any case you ( all ) have a simulated parallelism, know as concurrency and not a real parallelism. What i mean?! Parallelism : each processes have one CPU. Concurrency : One CPU for all processes that through OS scheduling policy simulate parallelism.

    So, you can modify scheduling policy and then create a parallel program with four processes, each with its threads. In any case your program never be parallel because you must divide your CPU with S.O. Runtime Support.
    ok..but for my project i need only four processes(threads) to run concurrently....so you have any idea how we can do that using multithreading in java....

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

    Default

    Quote Originally Posted by praveenbhushan1989 View Post
    ok..but for my project i need only four processes(threads) to run concurrently
    You didn't understand what he posted. Regardless of what you need, there are multiple processes occurring that you have no control over.


    ....so you have any idea how we can do that using multithreading in java....
    I agree with you that Java is a great language, and for many applications it is much better than C/C++, but I don't think that this is one of them. I think that the feasibility of this project is close to nil.

  10. #10
    Join Date
    Feb 2011
    Posts
    11
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    You didn't understand what he posted. Regardless of what you need, there are multiple processes occurring that you have no control over.




    I agree with you that Java is a great language, and for many applications it is much better than C/C++, but I don't think that this is one of them. I think that the feasibility of this project is close to nil.
    ok so how we can do that in c\c++ as i am not so good in c\c++......

  11. #11
    Bellerofonte is offline Member
    Join Date
    Feb 2011
    Location
    Rome, IT
    Posts
    4
    Rep Power
    0

    Default

    perhaps for the problems discussed, will not easy to solve parallelism problem with java, and than i think that it's not necessary. Your problem i think could be solved only with threads inside unique process, with an object such as container. I suggest to you DivideEtImpera Algorithm. This algorithm costs, in terms of time, is logaritmic in function of the input. This algoritm could be implemented by all threads. In my opinion, find a solution to optimize concurrency in a single CPU inside not embedded systems could be wrong. Spend much more time to find a batter approach to solve the problem, i think is the right way.

  12. #12
    Bellerofonte is offline Member
    Join Date
    Feb 2011
    Location
    Rome, IT
    Posts
    4
    Rep Power
    0

    Default

    i think that changing language to solve this problem is the wrong way. Also because your thread will always "concurrent" !!

  13. #13
    Join Date
    Feb 2011
    Posts
    11
    Rep Power
    0

    Default

    Quote Originally Posted by Bellerofonte View Post
    perhaps for the problems discussed, will not easy to solve parallelism problem with java, and than i think that it's not necessary. Your problem i think could be solved only with threads inside unique process, with an object such as container. I suggest to you DivideEtImpera Algorithm. This algorithm costs, in terms of time, is logaritmic in function of the input. This algoritm could be implemented by all threads. In my opinion, find a solution to optimize concurrency in a single CPU inside not embedded systems could be wrong. Spend much more time to find a batter approach to solve the problem, i think is the right way.
    could you elaborate your answer........ok i will try to find a better approach............

  14. #14
    lovelesh is offline Senior Member
    Join Date
    Nov 2010
    Location
    Delhi
    Posts
    135
    Blog Entries
    1
    Rep Power
    0

  15. #15
    Join Date
    Feb 2011
    Posts
    11
    Rep Power
    0

    Default

    thanks for your post.....

  16. #16
    Join Date
    Feb 2011
    Posts
    11
    Rep Power
    0

    Default implementing multithreading

    friends, see I am attaching this code..where i have 5 for loops inside a function called brute......i need to run each for loop as a separate thread..........could anyone tell me how to implement multithreading in those five for loops and get the correct result.......if anyone knows plz modify it and send me by attaching or give me some idea.........
    Attached Files Attached Files
    Last edited by praveenbhushan1989; 03-01-2011 at 01:21 AM. Reason: forgot attaching a file

Similar Threads

  1. Multithreading Gui
    By BUGSIE91 in forum Threads and Synchronization
    Replies: 7
    Last Post: 10-13-2010, 02:20 PM
  2. Want to know about Multithreading.
    By Chetans in forum Threads and Synchronization
    Replies: 1
    Last Post: 03-19-2010, 07:50 AM
  3. Log 4j Multithreading
    By joe2010 in forum Threads and Synchronization
    Replies: 1
    Last Post: 01-31-2010, 03:48 AM
  4. multithreading
    By shilpa.krishna in forum New To Java
    Replies: 2
    Last Post: 06-27-2008, 04:18 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
  •