Top Description Fields Constructors Methods
net.sf.ehcache.util

public Class FailSafeTimer

extends Object
Class Inheritance
Imports
java.util.Date, .Timer, .TimerTask

A fail-safe timer in the sense that if the runtime environment restricts creating new threads, it doesn't blow up with an exception. TimerTasks that are scheduled will run at least once (inline when they are scheduled) if creating threads is not allowed. For example, Google App Engine does not allow creation of new threads.

Clients should not use this as a general purpose timing service. To do so could interfere with the running of the Cache.

Author
Abhishek Sanoujam
Since
1.7

Field Summary

Modifier and TypeField and Description
private final Timer
private final boolean

Constructor Summary

AccessConstructor and Description
public
FailSafeTimer(String name)

Constructor accepting a name for the timer.

Method Summary

Modifier and TypeMethod and Description
public void
cancel()

If the runtime environment restricts thread creation, this method does nothing.

public int
purge()

If the runtime environment restricts thread creation, this method does nothing.

public void
schedule(TimerTask task, Date firstTime, long period)

If the runtime environment restricts thread creation, the task is run inline for only one time.

public void
schedule(TimerTask task, Date time)

If the runtime environment restricts thread creation, the task is run inline for only one time.

public void
schedule(TimerTask task, long delay, long period)

If the runtime environment restricts thread creation, the task is run inline for only one time.

public void
schedule(TimerTask task, long delay)

If the runtime environment restricts thread creation, the task is run inline for only one time.

public void
scheduleAtFixedRate(TimerTask task, Date firstTime, long period)

If the runtime environment restricts thread creation, the task is run inline for only one time.

public void
scheduleAtFixedRate(TimerTask task, long delay, long period)

If the runtime environment restricts thread creation, the task is run inline for only one time.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

timerback to summary
private final Timer timer
timerThreadRunningback to summary
private final boolean timerThreadRunning

Constructor Detail

FailSafeTimerback to summary
public FailSafeTimer(String name)

Constructor accepting a name for the timer. The scheduling thread is created as a daemon

Method Detail

cancelback to summary
public void cancel()

If the runtime environment restricts thread creation, this method does nothing.

See Also
java.util.Timer#cancel()
purgeback to summary
public int purge()

If the runtime environment restricts thread creation, this method does nothing.

See Also
java.util.Timer#purge()
scheduleback to summary
public void schedule(TimerTask task, Date firstTime, long period)

If the runtime environment restricts thread creation, the task is run inline for only one time. No further repeated execution happens for the task

See Also
java.util.Timer#schedule(java.util.TimerTask, java.util.Date, long)
scheduleback to summary
public void schedule(TimerTask task, Date time)

If the runtime environment restricts thread creation, the task is run inline for only one time. No further repeated execution happens for the task

See Also
java.util.Timer#schedule(java.util.TimerTask, java.util.Date)
scheduleback to summary
public void schedule(TimerTask task, long delay, long period)

If the runtime environment restricts thread creation, the task is run inline for only one time. No further repeated execution happens for the task

See Also
java.util.Timer#schedule(java.util.TimerTask, long, long)
scheduleback to summary
public void schedule(TimerTask task, long delay)

If the runtime environment restricts thread creation, the task is run inline for only one time. No further repeated execution happens for the task

See Also
java.util.Timer#schedule(java.util.TimerTask, long)
scheduleAtFixedRateback to summary
public void scheduleAtFixedRate(TimerTask task, Date firstTime, long period)

If the runtime environment restricts thread creation, the task is run inline for only one time. No further repeated execution happens for the task

See Also
java.util.Timer#scheduleAtFixedRate(java.util.TimerTask, java.util.Date, long)
scheduleAtFixedRateback to summary
public void scheduleAtFixedRate(TimerTask task, long delay, long period)

If the runtime environment restricts thread creation, the task is run inline for only one time. No further repeated execution happens for the task

See Also
java.util.Timer#scheduleAtFixedRate(java.util.TimerTask, long, long)