htw
htw

Reputation: 179

Run a function in the background while starting another function

I want to run a function in the background which checks every seconds a url.
I already have the function to check the url but I want to run this function every second and meanwhile I can start functions manually.
I hope you understand my question.

Thanks

Upvotes: 0

Views: 2204

Answers (1)

EnKrypt
EnKrypt

Reputation: 777

I think this is the right moment for you to use threads

Introduction to threads in java

Here's what you need to do:
In your program , before you start your manual functions and when you want to start checking that url , start a thread that loops every second which runs that url checking function.
In the main program , after you've started the thread , you can start running your manual functions

Upvotes: 1

Related Questions