feat: add advanced multithreading banking system skeleton
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package dev.banking.service;
|
||||
|
||||
import dev.banking.model.*;
|
||||
import dev.banking.processor.TransactionProcessor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
public class BankingSystem {
|
||||
|
||||
private final ExecutorService executor;
|
||||
private final TransactionProcessor processor;
|
||||
|
||||
public BankingSystem(
|
||||
ExecutorService executor,
|
||||
TransactionProcessor processor
|
||||
) {
|
||||
this.executor = executor;
|
||||
this.processor = processor;
|
||||
}
|
||||
|
||||
public void processTransactions(
|
||||
List<Transaction> transactions
|
||||
) {
|
||||
|
||||
for (Transaction tx : transactions) {
|
||||
|
||||
executor.submit(() -> {
|
||||
processor.process(tx);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user