Home > Back-end >  How to use the multithreading for loop problem
How to use the multithreading for loop problem

Time:10-17

Hi, I'm Java beginners, recent need to use Java for data filtering, but encountered problems, specific problems are as follows:
I need the choice of vehicle and parking problems, including car parking information will increase continuously in the loop (the last parking results need to use in the next cycle), the vehicle need to choose and it is the closest distance carparking space successfully, but a parking space in a certain period can only have a car, at this stage to use if statements are already in the parking vehicles attribute judgment, if the latest space has been occupied by a car, is to find the next vehicle recently, therefore involves a large number of circulation situation, late in the program is run (most of the parking lot is full), a cycle time is very long,
So I'll find some related information, know the multithreaded this concept, idea is for every car to find the behavior of the vehicle in a new thread, in order to reduce the total running time, about using multithreading, have any good Suggestions? This idea is feasible?

CodePudding user response:

Not feasible, will cause two cars parked in the same parking space
  • Related