java - How can I add functions to a priority queue? (Is it even possible) -


I know what the priority queue is and I know how to add strings / integers to it. But now I I want to add work for (If this makes sense ??) I am not ready to change the return type of a function.

I want to know how can I go about doing this? I have created a raw type preference queue

  priority quu prq = new priority question (); Prg.offer (login ());  

Now, I am not a coding genius, I am also learning. So I wanted to see what was possible. If this is not possible then is there any alternative solution?

My pop () function will only run the function that was pop-popping. Most of my work is zero I

I have an idea: should I include the string and what string statement should I make based on the pop?

Put return value of the function in the queue you are currently doing If the function is executed then the value that is generated is kept in the queue. Instead, you may have a line of runnable s and then call the run () method on them:

  priority question & Lt; Runnabel & gt; Queue = new priority question & lt; Runnabel & gt; (); Q.Offer (new Runnabal) {Public runs zero () {login ();}); Queue.remove () run () .;  

Or, if using Java 8:

  priority question & lt; Runnabel & gt; Queue = new priority question & lt; & Gt; (); Queue.offer (() -> Login (););  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -