AnyLogic - custom condition for last exit port in selectOutput5 [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Is there a way to specify a condition for the last exit port (fifth) in the selectOutput5 block and to ensure that if that condition is not met (false), the block will return to evaluating the condition for exit port 1, then exit port 2, and so on? The idea is to create kind of a loop, so that if none of the five conditions are met, it will return to evaluating condition 1 and so on.

Use the below configuration and add a very small delay time (e.g. 0.1 seconds)

Related

Continuous task waiting and suspend it [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
In a spring boot web application, I need to be able to do two tasks.
Tasks
Always check on the serial port if there is some data to read. Somebody can have passed a card on the scan. I think this task needs to start with the application.
If a new member comes, I need to scan a card, task 1 needs to be suspended/stopped... if the card is not assigned to anybody, it's assigned to this member. Restart task 1.
I don't know what is the best way to do task 1 to facilitate task 2.
I see there are many possibility: #Scheduled, TaskScheduler who will execute a thread...
Any suggestions?
You should make one Thread that reads data from the serial port in a loop and dispatches this data as events when something usefull was readed to a proper service that will serve this.

Starvation and threads [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have an interesting scenario based question related to java threads.
Sam has designed an application. I t segregates tasks that are critical and executed frequently from tasks that are non critical and executed less frequently. He has prioritized these tasks based on their criticality and frequency of execution. After close scrutiny, he finds that the tasks designed to be non critical are rarely getting executed. From what kind of problem is the application suffering?
I have figured it out as "Starvation" but i am still confuse whether I am right or wrong.
Starvation is a reasonable term for what is going on here. However, your lecturer might have something more specific in mind (... I'm not sure what ...) so check your lecture notes and text books.
... i am still confuse whether I am right or wrong.
If you stated why you are confused, we might be able to sort out your confusion.

Akka's ActorSystem Shutdown? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
please
how to shutdown actorSystem after all childs' actors finished
system().shutdown //cut actors work
i try to use
system().shutdown
but this cut other actors work
and schedule may finish before child actors finished
The Derek Wyatt's article Shutdown Patterns in Akka 2 (http://letitcrash.com/post/30165507578/shutdown-patterns-in-akka-2) gives the comprehensive answer to the question.
For testing this works just fine. You will be able to use sbt ~run
system.scheduler.scheduleOnce(20 seconds) {
println("shutdown")
system.shutdown
}

Main method 5th priority , which are the threads which are having higher priority that main method in java [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
We know that if we execute the getcurrentthread.priority method we will get the thread priority as 5. I am not able to get the answer for the threads having priority higher than the Main method.
I assume you mean that this is somehow the index of the thread in a priority queue, and that therefore at least 4 other threads must exist.
Well, this isn't the case, it's not an index but a value used to compare its priority with other concurrent threads, not only in your VM but also on your system. In fact, threads can have the same priority.
Side note: when setting the priorities on Threads, always use the constants MIN_PRIORITY, NORM_PRIORITY and MAX_PRIORITY. If you need intermediate values, calcuate them using the constants:
int mediumHighPriority = (Thread.NORM_PRIORITY+Thread.MAX_PRIORITY)/2;
The constant values may get changed in the future (could have a wider range, or even be reversed so that lower number equals higher priority, or the NORM_PRIORITY could get lower or higher), if you use the constants rather than their value you're on the save side and the code gets more legible.
You can enumerate all threads in the current program via ThreadGroup, see for example this answer.
When a java application is started, the JVM creates the main ThreadGroup as a member of the system ThreadGroup and set the priority to default(i.e NORM_PRIORITY).
This only applies to the threads in the current Java program though and will not provide any information about all the other threads running in other processes in the OS.

Java exception handling with retry [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Working on a small internet application, I need to deal with a service out-of-service situation. What is a good approach of retry after an exception?
The simplest solution (though maybe not the best) would be to return an error page to the user (with status 503: Service Unavailable), and tell him he should try again in a few seconds.
Depends on how long your application will be out of service but I will go with one of those :
- if the interruption is short less than one minute, loop and try to call the function/service/ ....
- if the interruption could be longer, you could use a JavaScript routine that would automatically refresh the page ... every 60s
- As Eran Zimmerman's answer, display an error page and advice the user to try again later
You don't want to beat your application to death with repeated retries. Returning an error page is not that bad an option. If you must retry (you have some flaky service where you can't cache the results) then use a backing-off approach where with each retry you double the time until the next try.

Categories