Skip to main content

All Questions

1 vote
1 answer
675 views

Java: Callback to main Thread

How can I make the callback execute in the "main thread"? @Test void threadTest() throws InterruptedException { System.out.println("main thread:" + Thread.currentThread()); ...
PeMa's user avatar
  • 1,638
0 votes
1 answer
2k views

How to properly do a thread callback in Java?

I am working on a project in Java (no Android). I have a thread that does some long work and I want a function in the main thread to be called when the work is done. I’ve seen many questions already ...
Day Trip's user avatar
3 votes
1 answer
4k views

kafka multi-threaded consumer with manual commit offset: KafkaConsumer is not safe for multi-threaded access

I use ArrayBlockingQueue to decouple Kafka consumers from sinks: Multi-threaded consumption of Kafka, one kafka consumer per thread; Kafka consumer manually manages the offset; The Kafka consumer ...
yewei.oyyw's user avatar
0 votes
2 answers
2k views

How ExecutorService works when submit a callable task with callback

How to add custom check in executorService.submit() callback. I want my thread not to do anything, whenever flag is true. If flag is false then it should work as usual. import org.apache.commons....
sanjiv ranjan's user avatar
2 votes
2 answers
822 views

How to realize a callback in android?

Maybe my knowledge about this topic is so small, that the word "callback" is not right here, sorry about that. If I start an thread in any class/activity/other thread and after finishing I want it to ...
HydroHeiperGen's user avatar
1 vote
0 answers
29 views

Read data from a helper class' thread subclass

I'm trying to create a NFC reader on a helper class, made on a thread subclass which runs the code which calls a device API. I've been looking lots of questions already and code examples on the ...
Hikaru Ryoko's user avatar
3 votes
1 answer
1k views

Reactive Programming in Java deep understanding

In order to have a deep understanding of Reactive Programming I was trying to reimplement, in a very simple way, the RxJava Observable class. This made me ask some important questions about reactive ...
Alessandro Argentieri's user avatar
0 votes
0 answers
132 views

Threads Callback return value

I have a class extending another class (which immplements Runnable) and implements a CallBack. A value gets changed inside the Thread and I'd like to return it to the test() method. Is there a way to ...
New Horizon's user avatar
0 votes
1 answer
1k views

synchronize database queries java

Hi I have a java program with multiple threads querying an HSQL database. I'm getting some very weird results from the queries and my guess is that the database is not set up to handle many queries at ...
Duane Allman's user avatar
0 votes
1 answer
89 views

asynchronous programming using callbacks in android

I would like to know how can we do asynchronous programing in android, I read that asynchronous programming is not necessarily multithreaded(where this applies?), how can we do it in android because ...
blackHawk's user avatar
  • 6,247
1 vote
0 answers
632 views

Waiting for a callback method to be called in Android

I am writing an android application which interacts with a sensor using bluetooth and obtains temperature values. I am doing this by calling connectGatt() which is asynchronous and calls a callback ...
karthik93's user avatar
0 votes
0 answers
225 views

Wait for response in the main Java class after calling the instance and fuction in other Java class in Android Studio

Due to the delay in api call and response the data is not getting in time and I'm using delay to get reponse. If there the reponse is delayed more than my timer limit I get null error. Is there any ...
Joshan Tandukar's user avatar
0 votes
0 answers
24 views

Keep Old Value in Catch Block in Java(Exception Handling) [duplicate]

Ok so here is the scenario from an interview I had recently. It took me a long time, but I still couldn't figure it out. Suppose I have a standard try, catch finally block. public int portNumber ...
James Xia's user avatar
  • 173
0 votes
1 answer
2k views

Java Spark: Non-blocking routes / callbacks with CompletableFutures

I have to make calls to long running methods in a Spark API implementation. These methods return CompletableFutures, so I'd like to free up the current Thread by triggering Spark to answer the client ...
edr's user avatar
  • 436
0 votes
1 answer
112 views

synchronized on an object monitor or in my case is better a semaphore?

I have a doubt if my method is thread safe or not on the contrary I pretty sure is not thread safe, but I didn't yet found a solution. The following is my code: class TestLockSingleton { ...
aeroxr1's user avatar
  • 1,064

15 30 50 per page