Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

I want to read bulk of gmail and store it in my local disk. It takes 20 seconds for reading one mail and save it in the local. I want to reduce it by 5 sec. how can i use the producer consumer logic for this one.
- santhosh
There are two threads. One thread (T1) writes strings in a shared queue (Q) and the other (T2) reads from the queue and prints them. Implement T1 and T2. Note you cannot read from an empty queue and you cannot write to a full queue. You have the following operators CreateEvent #EventName #EventName.Set #EventName.Reset EnterCriticalSection LeaveCrticalSection LOOP END LOOP WAIT #EventName please provide solution
- akanksha
Hi, sir if we want to get output like synchronous way like… producer 0 cosumer 0 producer1 consumer1 producer2 cosumer2 . . . .
- vishal
HI Pankaj, Wont sleep be a blocking call. I mean when the producer starts the sleep it will not release the lock on the q that is shared . The consumer will then have to wait to access the queue. Isnt this code blocking …
- Anshul Gupta
Hello Sir, I am running the same code given by you in above example but its showing given below output: Produced Messagedemo.Message@247cb66a consumednull Not as above given by you.And after adding toString() method in the Consumer class at belwo line it is throwing null pointer exception. System.out.println(“consumed” +msg.getMsg().toString()); Exception in thread “Thread-1” java.lang.NullPointerException at demo.Consumer.run(Consumer.java:24) at java.lang.Thread.run(Unknown Source) Will you please correct me ? Do I need to syncronized them?
- Shweta
i want to create a concurrent asynchronous queue so that the messages or data can be inserted into it using threadpool and another pool retrieves data from the queue and stores it in database (asynchronously) how can i do this if anyone knows about it then please share the code or explain me how to implement it…
- Ahmed
Hi Pankaj, Could you kindly put a few more examples where BlockingQueue has been implemented for a larger service e.g. a real-time message queue where it’s being run for almost infinite duration. BTW - This example helps me a lot though! Kindest Regards,
- Mohammed Manna