I'm writing code using Executor java framework and I'm testing my code on Eclipse, but I saw a strange thing. Using debug mode on eclipse I can print on console an output, or better when I use debug mode step into(F5) I can print an output on console, but if I use debug mode, using step return(F7) or I run the application, it print nothing on console.
Below my output before with debug mode step into(F5):
mapBuffer
[[B@1af2d44a, [B@18d87d80, [B@618425b5, [B@58695725, [B@543588e6, [B@f5acb9d, [B@4fb3ee4e]
and after with debug mode with step return(F7) or run application:
mapBuffer
[]
With the same code I have two different output.
public boolean readPieceCount() throws IOException {
//byte[] buffer = null;
SortedMap<Integer,byte[]> mapBuffer=new TreeMap<>();
ExecutorService executor = Executors.newFixedThreadPool(1);
executor.submit(() -> {
for (Integer i=0; i<NUMFILES;i++)
{
Path path = Paths.get(pathPieceCount+"pieceCount"+(i+1)+".csv");
if(Files.exists(path, LinkOption.NOFOLLOW_LINKS))
{
byte[] buffer = null;
try {
buffer = Files.readAllBytes(path);
mapBuffer.put(i+1, buffer);
} catch (IOException e) {
System.out.println("Exception on readPieceCount!!!");
}
}
}
});
System.out.println("mapBuffer ");
System.out.println(mapBuffer.values());
executor.shutdown();
/*
more code
*/
this is a part of my code where I have the problem.
I would like to have the same result in all mode. Honestly I spent lots of time yesterday but I'm not understanding where getting wrong. Only a confirmation. When I run this part of code,always I will obtain the same sequence of buffer on the map or executor can change the sequence?