Stay organized with collections
Save and categorize content based on your preferences.
CallerRunsPolicy
open class CallerRunsPolicy : RejectedExecutionHandler
A handler for rejected tasks that runs the rejected task directly in the calling thread of the execute
method, unless the executor has been shut down, in which case the task is discarded.
Summary
Public constructors |
Creates a CallerRunsPolicy .
|
Public methods |
open Unit |
Executes task r in the caller's thread, unless the executor has been shut down, in which case the task is discarded.
|
Public constructors
CallerRunsPolicy
CallerRunsPolicy()
Creates a CallerRunsPolicy
.
Public methods
rejectedExecution
open fun rejectedExecution(
r: Runnable!,
e: ThreadPoolExecutor!
): Unit
Executes task r in the caller's thread, unless the executor has been shut down, in which case the task is discarded.
Parameters |
r |
Runnable!: the runnable task requested to be executed |
executor |
the executor attempting to execute this task |
e |
ThreadPoolExecutor!: the executor attempting to execute this task |
Exceptions |
java.util.concurrent.RejectedExecutionException |
if there is no remedy |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# ThreadPoolExecutor.CallerRunsPolicy\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nCallerRunsPolicy\n================\n\n```\nopen class CallerRunsPolicy : RejectedExecutionHandler\n```\n\n|---|---------------------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy](#) |\n\nA handler for rejected tasks that runs the rejected task directly in the calling thread of the `execute` method, unless the executor has been shut down, in which case the task is discarded.\n\nSummary\n-------\n\n| Public constructors ||\n|---------------------------------------------------------------------------|---|\n| [CallerRunsPolicy](#CallerRunsPolicy())`()` Creates a `CallerRunsPolicy`. |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [rejectedExecution](#rejectedExecution(java.lang.Runnable,%20java.util.concurrent.ThreadPoolExecutor))`(`r:` `[Runnable](../../lang/Runnable.html#)!`, `e:` `[ThreadPoolExecutor](/reference/kotlin/java/util/concurrent/ThreadPoolExecutor)!`)` Executes task r in the caller's thread, unless the executor has been shut down, in which case the task is discarded. |\n\nPublic constructors\n-------------------\n\n### CallerRunsPolicy\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nCallerRunsPolicy()\n```\n\nCreates a `CallerRunsPolicy`.\n\nPublic methods\n--------------\n\n### rejectedExecution\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun rejectedExecution(\n r: Runnable!, \n e: ThreadPoolExecutor!\n): Unit\n```\n\nExecutes task r in the caller's thread, unless the executor has been shut down, in which case the task is discarded.\n\n| Parameters ||\n|------------|--------------------------------------------------------------------------------------------------------------------------------|\n| `r` | [Runnable](../../lang/Runnable.html#)!: the runnable task requested to be executed |\n| `executor` | the executor attempting to execute this task |\n| `e` | [ThreadPoolExecutor](/reference/kotlin/java/util/concurrent/ThreadPoolExecutor)!: the executor attempting to execute this task |\n\n| Exceptions ||\n|---------------------------------------------------|-----------------------|\n| `java.util.concurrent.RejectedExecutionException` | if there is no remedy |"]]