• Post Reply Bookmark Topic Watch Topic
  • New Topic

the Race  RSS feed

 
jc
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
need to find some coding for the "hare and the tortoise race"...
anybody know where I could find this....
 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jc,

Welcome to Javaranch. We follow some rules pertaining to User names. The rules are
specified at here
Your User name does not follow these conventions. It is recommended
that you immediately register under a name conforming to the conventions.
 
laney coll
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
changed it!
now, can you help me!
 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please clarify what exactly you need so that i can work on it.
 
laney coll
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to find coding for this race which includes the use of threads and outputs all moves made by the hare/tortoise to an output file
any help would be greatly appreciated.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting that this question should come up over and over. Methinks someone is using it for a homework assignment.
http://www.javaranch.com/ubb/Forum1/HTML/000845.html
 
laney coll
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
me thinks posting above not very helpful
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The purpose of assignments is only realised if you do the bulk of them yourself. Therefore, if this is indeed an assignment, I hope you will get only helpful hints and not the canned solution you appear to be asking for.
Maybe you can tell us where specifically you are stuck, so we can help you?
- Peter
 
laney coll
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not really sure on how to output information to an output file
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by laney coll:
I'm not really sure on how to output information to an output file

PrintWriter file = new PrintWriter(new BufferedWriter(new FileWriter("myfile.txt")));
...
synchronized(file) { file.println("foo bar"); }
Use a synchronized block because you will presumably be writing to "file" from more than one thread. If you have a lot of print statements, you will probably want to wrap "file" in a synchronized object so you can dispense with the synchronized blocks.
- Peter
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!