{"id":18789190,"url":"https://github.com/dsiner/taskscheduler","last_synced_at":"2025-08-02T16:37:16.394Z","repository":{"id":202173186,"uuid":"133646662","full_name":"Dsiner/TaskScheduler","owner":"Dsiner","description":"Thread Pool. Task/Thread switching, scheduling, without RxJava2; 线程池、线程切换、任务调度","archived":false,"fork":false,"pushed_at":"2020-12-24T13:33:00.000Z","size":154,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T05:02:05.809Z","etag":null,"topics":["flow","scheduler","task","thread","thread-pool"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dsiner.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-05-16T10:02:15.000Z","updated_at":"2021-08-27T05:10:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"4513ca4e-5557-481c-afa2-8cd71a6bdcdc","html_url":"https://github.com/Dsiner/TaskScheduler","commit_stats":null,"previous_names":["dsiner/taskscheduler"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dsiner%2FTaskScheduler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dsiner%2FTaskScheduler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dsiner%2FTaskScheduler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dsiner%2FTaskScheduler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dsiner","download_url":"https://codeload.github.com/Dsiner/TaskScheduler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248721296,"owners_count":21151076,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flow","scheduler","task","thread","thread-pool"],"created_at":"2024-11-07T21:06:55.373Z","updated_at":"2025-04-13T13:32:25.854Z","avatar_url":"https://github.com/Dsiner.png","language":"Java","readme":"# TaskScheduler for Android\n\n[![License](https://img.shields.io/badge/license-Apache%202-green.svg)](https://www.apache.org/licenses/LICENSE-2.0)\n[![API](https://img.shields.io/badge/API-9%2B-green.svg?style=flat)](https://android-arsenal.com/api?level=9)\n[![Download](https://api.bintray.com/packages/dsiner/maven/taskscheduler/images/download.svg) ](https://bintray.com/dsiner/maven/taskscheduler/_latestVersion)\n\n\u003e TaskScheduler is a library for composing asynchronous and event-based programs by using observable sequences.\n\n## Set up\nMaven:\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.dsiner.lib\u003c/groupId\u003e\n  \u003cartifactId\u003etaskscheduler\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\nor Gradle:\n```groovy\ncompile 'com.dsiner.lib:taskscheduler:1.0.2'\n```\n\n## Getting started\n\nExecute sync task in main thread\n\n```java\n        TaskScheduler.executeMain(new Runnable() {\n            @Override\n            public void run() {\n                ...do something in main thread\n            }\n        });\n```\n\nExecute async task in cached thread pool\n\n```java\n        TaskScheduler.executeTask(new Runnable() {\n            @Override\n            public void run() {\n                ...do something in asynchronous thread\n            }\n        });\n```\n\nExecute async task in single thread pool\n\n```java\n        TaskScheduler.executeSingle(new Runnable() {\n            @Override\n            public void run() {\n                ...do something in asynchronous thread\n            }\n        });\n```\n\nExecute async task in a new thread\n\n```java\n        TaskScheduler.executeNew(new Runnable() {\n            @Override\n            public void run() {\n                ...do something in asynchronous thread\n            }\n        });\n```\n\nCreate task\n\n```java\n        TaskScheduler.create(new Task\u003cList\u003cString\u003e\u003e() {\n            @Override\n            public List\u003cString\u003e run() {\n                ...do something in io thread\n                return new ArrayList\u003c\u003e();\n            }\n        }).subscribeOn(Schedulers.io())\n                .observeOn(Schedulers.newThread())\n                .map(new Function\u003cList\u003cString\u003e, String\u003e() {\n                    @Override\n                    public String apply(@NonNull List\u003cString\u003e strings) throws Exception {\n                        ...do something in a new thread, such as time-consuming, map conversion, etc.\n                        return \"\";\n                    }\n                })\n                .observeOn(Schedulers.io())\n                .map(new Function\u003cString, Boolean\u003e() {\n                    @Override\n                    public Boolean apply(@NonNull String s) throws Exception {\n                        ...do something in io thread, such as time-consuming, map conversion, etc.\n                        return true;\n                    }\n                })\n                ...\n                .observeOn(Schedulers.mainThread())\n                .subscribe(new Observer\u003cBoolean\u003e() {\n                    @Override\n                    public void onNext(@NonNull Boolean result) {\n                        ...do something in main thread\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        ...do something in main thread\n                    }\n                });\n```\n\n## Latest Changes\n- [Changelog.md](CHANGELOG.md)\n\n## Licence\n\n```txt\nCopyright 2018 D\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsiner%2Ftaskscheduler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdsiner%2Ftaskscheduler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsiner%2Ftaskscheduler/lists"}