- List<TransactionListItem> transactions = Data.transactions.get();
- if (transactions == null) return null;
- if (position >= transactions.size() + 1) return null;
- if (position == transactions.size()) return new TransactionListItem();
- return transactions.get(position);
- }
- public static int getTransactionCount() {
- List<TransactionListItem> transactions = Data.transactions.get();
- if (transactions == null) return 0;
- return transactions.size();
+ try(LockHolder lh = Data.transactions.lockForReading()) {
+ if (Data.transactions == null) return null;
+ if (position >= Data.transactions.size() + 1) return null;
+ if (position == Data.transactions.size()) return new TransactionListItem();
+ return Data.transactions.get(position);
+ }