Results 1 to 4 of 4
  1. #1
    Zosden's Avatar
    Zosden is offline Senior Member
    Join Date
    Apr 2008
    Posts
    384
    Rep Power
    7

    Default Nqueens with threads

    If your not familiar with nqueens then wiki it. What if you made a class that implmented runnable and had a thread in it then us used that class to work as a layer of the nqueens problem this class would in turn call another class that would work on the next level. Would this make the solution even faster or what. If yes then why not use such solutions in advanced algorithms today. If not then why isn't it faster.
    My IP address is 127.0.0.1

  2. #2
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    7

    Default

    This is called parallelization, to do that - you have to be able to split the problem in divisional aspects such that no two threads are trying to "work on the same part of the problem" .. trying to dissect exactly what that means is how one would parallelize N-Queens or Ant Colony Optomization or any of a broad class of problems that can be sifted on the single factor of the ability to compartmetnalize the logic.

    Java has built in synchronization primitives, and in general they are implemented well except that the HotSpot has one or two misplaced register stores that cross subtle boundaries because of the wording in the Spec.

    Google for Java Real Time Specification, your work would be welcome.

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

    Default

    Wouldn't this also depend upon whether or not the computer running the code had multiple processors, and whether or not the JVM would split the different threads amongst the different processors. If all done on one processor, I don't see how multiple threads would give you any gain at all.

  4. #4
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    7

    Default

    Threading on uniprocessor machines has proven gains in io, otherwise it is as you state. Technically, due to L-2 writebacks there may be minor gains avaliable, in a core loop for a heavy load, the gain may be measurable ~ but it would depend totally on a JVM implementation on a paticular hardware and OS and ( not to dismiss the depth of your observation ) also depend on weather patterns, operator luck and so on.

    If the N-Queens has a layerable aspect, I would naturally have a Threading solution as a goal, but making a single class Runnable then getting layers out of it does not sound to me like an effective approach. We could consider making a class that takes an OrderedPair then doing a foreach{new Runnable();} as todays machines have ablilities to do deep branch prediction and speculative instruction execution that could outrun L-2.

    Mind Boggling to say the least. I like to have my mind boggled.

Similar Threads

  1. help with networking and threads
    By byuu in forum Networking
    Replies: 9
    Last Post: 05-21-2008, 05:03 AM
  2. Threads!
    By rameshraj in forum Advanced Java
    Replies: 1
    Last Post: 05-04-2008, 04:11 PM
  3. How to use Java threads
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-09-2008, 06:30 PM
  4. Using threads
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-11-2007, 10:25 AM
  5. Threads
    By one198 in forum Threads and Synchronization
    Replies: 1
    Last Post: 11-20-2007, 06:15 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
  •