• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

the Race

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
need to find some coding for the "hare and the tortoise race"...
anybody know where I could find this....
 
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
changed it!
now, can you help me!
 
Rahul Mahindrakar
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
me thinks posting above not very helpful
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not really sure on how to output information to an output file
 
Peter den Haan
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic