|
World world = new World(); |
Creating object of World class inside Thread's Run method doesn't make sense, as every time it is creating new object and reading the file. It should be outside this thread's run method.
for now it is like this
executorService.scheduleAtFixedRate(new Runnable() {
@OverRide
public void run() {
World world = new World();
List countries = world.fetch();
but it should be like this
executorService.scheduleAtFixedRate(new Runnable() {
World world = new World();
@OverRide
public void run() {
List countries = world.fetch();
java-design-patterns/dirty-flag/src/main/java/com/iluwatar/dirtyflag/App.java
Line 60 in fedc2d9
Creating object of World class inside Thread's Run method doesn't make sense, as every time it is creating new object and reading the file. It should be outside this thread's run method.
for now it is like this
executorService.scheduleAtFixedRate(new Runnable() {
@OverRide
public void run() {
World world = new World();
List countries = world.fetch();
but it should be like this
executorService.scheduleAtFixedRate(new Runnable() {
World world = new World();
@OverRide
public void run() {
List countries = world.fetch();