Suppose I need to process files in a given folder in parallel. In Java I would create a FolderReader
thread to read file names from the folder and a pool of FileProcessor
threads. FolderReader
reads file names and submits the file processing function (Runnable
) to the pool executor.
In Scala I see two options:
- create a pool of
FileProcessor
actors and schedule a file processing function with Actors.Scheduler
.
- create an actor for each file name while reading the file names.
Does it make sense? What is the best option?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…