Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Multi Threading  RSS feed

 
Vlad Anghene
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I've been asked to do an assignment on multi threading and I'd like to choose a topic that's nice and appropriate to base my code on. And mind you, I don't want to add two vectors in separate threads.
Do you guys have any ideas / references you might point me to (links, books even) where there's a nice and thorough treatment of this subject ?
Much obliged,
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Have you checked out https://docs.oracle.com/javase/tutorial/essential/concurrency/
It is comprehensive and covers all important aspects. Of course in case you run into problems, you can always post here!

Nice appropriate topic?
25 college kids walk into a bar. There are 2 bartenders. Being well mannered, the kids queue up nicely, each awaiting his/her turn. As soon as a bartender is free, they step forward and place their individual order.
Considering the orders are different, come up with a code which will demonstrate time taken by each bartender, ids of kids served, sequence served and the total time elapsed till all kids sit at a table and hoist their glasses.
 
Jason Bullers
Ranch Hand
Posts: 111
8
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh's idea sounds fun.

If you want something trickier, you could also do something along the lines of a synchronization problem I remember from my OS course back in University. Hopefully I remember the details correctly...

You have two food dishes, two mice, and six cats. The goal is that all eight animals get to eat, except that a cat and a mouse can't be at the bowls at the same time (otherwise the cat will eat the mouse!). Both bowls should be in use when possible, so you can't just queue all the animals on one bowl. I think the length of time each animal spent eating, and how long before it needed to eat again was random, so you can't just set up some sort of round robin, because then throughput suffers.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!