Questions tagged [consumer]

649 questions
-2
votes
1 answer

Java asynchronous return of CompletableFuture

If we have AsyncResponse response variable we can write something like: CompletableFuture#thenAccept(response::resume). I don't understand how can we pass boolean resume(Object response) method from AsyncResponse class to thenAccept() which takes…
Freeman
  • 232
  • 1
  • 2
  • 11
-2
votes
1 answer

The problem of this code is in the output. Producer produce more than once. Why and how can I solve it?

The problem of this code is in the output. Producer produce more than once. Why and how can I solve it? After each producer should following a consumer. This code can be pasted in IDE and directly run. I think the problem is in the variable ready. I…
David
  • 1
  • 3
-3
votes
2 answers

incompatible types: bad return type in lambda expression | void is not a functional interface

I am going through Java 8 Feature and using Jshell to explore it. I tried to run the below command: Consumer consumer = (str)->System.out::println; But it failed with the below error: Error: | incompatible types: bad return type in lambda…
Manish
  • 1,274
  • 3
  • 22
  • 59
-3
votes
1 answer

Write Map in File with Consumer in Java 8

I want to write a class MapWriter that Implements a Consumer of Map that writes the input map into a text file. I have a final attribute outputFilePathStr. @AllArgsConstructor public class MapWriter implements…
Omar Krichen
  • 163
  • 1
  • 2
  • 12
1 2 3
43
44