Question: I've just recently started using hibernate and so I apologize if this is a stupid question.

I want to package some of my code into a module which different applications can then utilize.
For example, a package that handles sending SMS messages.
This package does some database work to get basic config data and then might do some transaction logging.
This will then be added to applications requiring SMS functionality.
The package would therefore require the calling application to contain the specific config and logging tables required by the package.

My problem is that in order to write the hibernate methods that get the config and do the logging it needs to know of the hibernate specific DOA objects. The problem is these objects are only generated when we create the specific application database mapping.

Answer: 
It depends on what you are wanting to do. A simple sleep will suffice for your trivial example of waiting 10 sec between "Hello"s since you might as well suspend your current thread until your time is up.

Things get more complicated if your thread is actually doing something while you are waiting. If you are responding to incoming connections, you will already be using `select` in such a case a timeout to your `select` statement makes the most sense for your housekeeping.

If you are processing stuff in a tight loop, you might regularly poll a start time to see if your 10 seconds are up.

`alarm` with an appropriate signal handler will work as well but there are severe limits to what you can do in a signal handler. Most of the time, it involved setting a flag that will need to be polled every so often.

In a nutshell, it comes down to how your thread is processing events.
If your program is already threaded, then using a poll thread is simple and effective.

If your program is not already threaded, then it gets trickier. Can you use a separate process to do the job? If so, then using multi-processing instead of multi-threading.

If you cannot use an autonomous thread of control (process or thread), then it depends on how your program is organized, which is why there are many preferred alternatives (they are preferred for different circumstances). It also depends on the accuracy of timing that you require. With multi-second gaps and no hard real-time response requirement, you might use an alarm and the SIGALRM handler can set a flag and your main processing loop can monitor the flag at convenient, sensible points and do the activity. This is somewhat messy (because signals are messy), but without a more detailed description of your requirements and constraints, it is hard to know what else to suggest.

So, in summary, there isn't a single universally best solution because different programs are written in different styles and under different constraints.