Skip to content

swastikaAccolite/FishPoolProblem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FishPoolProblem

10 male and 10 female fishes are added to an infinite pond. Fishes randomly meet other fish in the pond according to the rules.

  1. If two male fishes meet they kill each other
  2. If two female fishes meet one of them dies at random
  3. If male and female fish meet they spawn two new fishes of random gender
  4. Fishes which are in meeting cannot be used by other threads

Simulate the infinite pond using 5 threads. Print the number of fishes remaining after each meeting. If all the fishes are dead, terminate the program.

Hint : Use Arraylist and java.util.Random

About

FishPool problem using java.util.random

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages