run and update dynamic array every x minute [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 7 years ago.
Improve this question
I have array with size of 80000, the array updates itself in infinity loop,
and has about 1000+/- hits per second in O(1).
i need to create function that run every one minute exactly and what the function does is go through all the dynamic array and update a particular field inside every cell in the array.
How can I create that function that running on dynamic array?
maybe with threads?

To create function that run every one minute you can use TimerTask for that
Whether to use Thread or not depends on your business logic
(How you are updating array ,can it be in background,is it updated from network(Web service call)?. etc).use Thread only you need to improve responsiveness of your proceess/application

Related

Limit requests to x times a minute with y times a second [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 days ago.
Improve this question
I have an api which allows me to run 180 requests every minute. However, if I request more than 50 times in a second, I will get temporarily banned. I have a thread class which sends the api request and performs and action on it. Assuming the class is called ApiRequestThread, what would I do? This is in java
I have used a mix of double guava ratelimiter but I wanted to know if anyone had any better ideas

how to implement a variable whose value is not lost after every run? [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 7 years ago.
Improve this question
I wish to implement a variable (in Java) whose value is either stored somewhere or is not reset every time I run the program.
It's related to a "Booking reference Number" for a flight program. I know database connectivity but make a new data base for one variable is pretty pointless. Any ideas as to what I should/can do?
Also I don't want the numbers to be random I want them in order like if the first booking ID is 100 then the next one should be 101 and so on.
Organize your data in a structure and then serialize it.When you re-run your program, look for that serialized version in the file system, if there is any, read it. Viola.!
You should write the variable to a file and then read it from the file the next time you run the program.

*ignore* How to check if an Array<String> contains an item that starts with a value [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 7 years ago.
Improve this question
The app fetches data from a server. The data is returned in an Array. I need to check if one of the Array items starts with a value specified in the app. If it's possible without iterating because that slows down the app significantly.
If you have just an array data structure, there is no way to check what it contains without actually looking into it.
However if you use a different data structure such as a HashMap (which is built on to of an array) you can check/lookup a key like "101" in O(1) time typically. You can check map.isEmpty() in O(1) time.
In short, if it's taking too long to perform a simple operation, chances are you need to be using a different data structure (or possibly more than one)

implement thread in java [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 7 years ago.
Improve this question
I want to maintain thread pool, and it should contain multiple jobs. Job has execute one after another
If you have a sequential execution of four jobs, you probably want to aggregate them into a single Runnable.
void run(){
job4(job3(job2(job1(inputs))));
}
It does not make much sense to schedule separate threads for the jobs (as only one of them can proceed at the same time).
You could submit that whole thing as one to an ExecutorService.

How to search database within less time [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 9 years ago.
Improve this question
I have near about 1 million entries in my database table and
I need to use some logic by which I can search within minimum time,
is there any algorithms or logic by which i can get result within less time.
I tried sorting table alphabetically but till it is taking much more time.
If you have any algorithm or logic then please suggest code in Java.
Looks like you need to ad in index to your database table.
If you tell what database you are using, people can give more specific help.
It dosent matter how much records you have as long as your databse is properly normalised and is having proper index. Having said that, the only difference that will make is how you are using indexes. You cannot do much in java, but your db and its design will play a significant role.

Categories

Resources