'difference between Thread state blocked and waiting [duplicate]
I have read the answer through the following posting: Difference between WAIT and BLOCKED thread states However, I am still puzzled.
I want to know what is the difference on the JVM level and what is the difference on the CPU level.
Whether both of these have the "Thread Context switch"? , which is faster on a multithreaded environment?
Solution 1:[1]
Waiting state is when thread intentionally called the wait() method . It means it waiting for some event/action to complete. Its like you go to customer care and queue is empty. You are waiting for your wife to arrive with Warranty card. So you are intentionally waiting.
But In the BLOCKED state, Thread is ready to run but other events blocked it for some reason. Like a thread is about to enter a synchronized block, but there is another thread currently running inside a synchronized block on the same object.
Another example is multiple thread called wait method for some event to complete . Once that event is completed, notifyAll() is called. Then only one thread will get CPU cycle others will still be blocked
Its like you go to customer care and no customer representative is present. You are blocked.
Solution 2:[2]
You definitely can obtain ApplePay/GooglePay token directly from Apple/Google, and use it to exchange for a Stripe token to "get into Stripe's world", similar to your original approach. However this approach requires some tweak and you would want to reach out to their Support.
Solution 3:[3]
Yes, it is possible to implement the flow you described with Stripe.
Refer to https://github.com/google-pay/pay-server-demos/blob/main/google-pay-psp-client/handlers/stripe.js for an example of how you might implement it for Google Pay:
return stripe(config.secretKey).charges.create({
amount: order.totalInt,
currency: order.currency.toLowerCase(),
source: order.paymentToken.id,
});
order.paymentToken.id is the payment token returned by Google Pay.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | orakaro |
| Solution 3 | Soc |
