1

I use web3j to fetch information from ethereum blockchain,

public static void main(String[] args) throws InterruptedException {
    Web3j web = Web3j.build(new HttpService("http://10.9.59.138:18001"));
    Observable<EthBlock> observable = web.blockObservable(true);
    Subscription subscription = observable.subscribe(System.out::println);
    Thread.sleep(3000);
    subscription.unsubscribe();
    System.out.println("main say good bye.");
    // jvm not exit!
}

As mentioned in the official document, subscriptions should always be cancelled when no longer required. So I call unsubscribe(), but the JVM not exit. How can I quit properly?

0

Although your code worked for me, you can ensure a proper exit by calling:

System.exit(0);
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.