{"id":3736,"date":"2013-05-19T13:09:15","date_gmt":"2013-05-19T10:09:15","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=3736"},"modified":"2013-05-19T15:23:44","modified_gmt":"2013-05-19T12:23:44","slug":"android-thread-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/","title":{"rendered":"Android Thread Example"},"content":{"rendered":"<p>In this example we are going to see how to use Android\u00a0<code><a href=\"http:\/\/developer.android.com\/reference\/java\/lang\/Thread.html\">Thread<\/a><\/code>. As we \u00a0read from the official documentation:<\/p>\n<ul>\n<li>A\u00a0<code>Thread<\/code>\u00a0is a concurrent unit of execution. It has its own call stack for methods being invoked, their arguments and local variables. Each virtual machine instance has at least one main\u00a0<code>Thread<\/code>\u00a0running when it is started; typically, there are several others for housekeeping. The application might decide to launch additional\u00a0<code>Thread<\/code>s for specific purposes.<\/li>\n<li><code>Thread<\/code>s in the same VM interact and synchronize by the use of shared objects and monitors associated with these objects. Synchronized methods and part of the API in\u00a0<code><a href=\"http:\/\/developer.android.com\/reference\/java\/lang\/Object.html\">Object<\/a><\/code>\u00a0also allow\u00a0<code>Thread<\/code>s to cooperate.<\/li>\n<li>There are basically two main ways of having a\u00a0<code>Thread<\/code>\u00a0execute application code. One is providing a new class that extends\u00a0<code>Thread<\/code>\u00a0and overriding its\u00a0<code><a href=\"http:\/\/developer.android.com\/reference\/java\/lang\/Thread.html#run()\">run()<\/a><\/code>\u00a0method. The other is providing a new\u00a0<code>Thread<\/code>\u00a0instance with a\u00a0<code><a href=\"http:\/\/developer.android.com\/reference\/java\/lang\/Runnable.html\">Runnable<\/a><\/code>object during its creation. In both cases, the\u00a0<code><a href=\"http:\/\/developer.android.com\/reference\/java\/lang\/Thread.html#start()\">start()<\/a><\/code>\u00a0method must be called to actually execute the new\u00a0<code>Thread<\/code>.<\/li>\n<li>Each\u00a0<code>Thread<\/code>\u00a0has an integer priority that basically determines the amount of CPU time the\u00a0<code>Thread<\/code>\u00a0gets. It can be set using the\u00a0<code><a href=\"http:\/\/developer.android.com\/reference\/java\/lang\/Thread.html#setPriority(int)\">setPriority(int)<\/a><\/code>\u00a0method. A\u00a0<code>Thread<\/code>\u00a0can also be made a daemon, which makes it run in the background. The latter also affects VM termination behavior: the VM does not terminate automatically as long as there are non-daemon threads running.<\/li>\n<\/ul>\n<p>For this tutorial, we will use the following tools in a Windows 64-bit platform:<\/p>\n<ul>\n<li>JDK 1.7<\/li>\n<li>Eclipse 4.2 Juno<\/li>\n<li>Android SKD 4.2<\/li>\n<\/ul>\n<h3>1. Create a new Android Project<\/h3>\n<p>Open Eclipse IDE and go to File -&gt; New -&gt; Project -&gt; Android -&gt; Android Application Project.\u00a0You have to specify the Application Name, the Project Name and the Package name in the appropriate text fields and then click Next.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/create-new-project-attrs3.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3737\" alt=\"create-new-project-attrs\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/create-new-project-attrs3.jpg\" width=\"550\" height=\"430\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/create-new-project-attrs3.jpg 550w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/create-new-project-attrs3-300x234.jpg 300w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>In the next window make sure the \u201cCreate activity\u201d option is selected in order to create a new activity for your project, and click Next. This is optional as you can create a new activity after creating the project, but you can do it all in one step.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/check-create-new-activity8.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3739\" alt=\"check-create-new-activity\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/check-create-new-activity8.jpg\" width=\"538\" height=\"483\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/check-create-new-activity8.jpg 538w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/check-create-new-activity8-300x269.jpg 300w\" sizes=\"(max-width: 538px) 100vw, 538px\" \/><\/a><\/p>\n<p>Select \u201cBlankActivity\u201d and click Next.<\/p>\n<p><a href=\"http:\/\/cdn.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/create-blanc-activity.jpg\"><img decoding=\"async\" alt=\"create-blanc-activity\" src=\"http:\/\/cdn.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/create-blanc-activity.jpg\" width=\"528\" height=\"502\" \/><\/a><\/p>\n<p>You will be asked to specify some information about the new activity. \u00a0In the Layout Name text field you have to specify the name of the file that will contain the layout description of your app. In our case the file\u00a0<code>res\/layout\/main.xml<\/code>\u00a0will be created. Then, click Finish.<\/p>\n<p><a href=\"http:\/\/cdn.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-activity-attr.jpg\"><img decoding=\"async\" alt=\"new-activity-attr\" src=\"http:\/\/cdn.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-activity-attr.jpg\" width=\"484\" height=\"455\" \/><\/a><\/p>\n<h3>2. Create the main layout of the Application<\/h3>\n<p>Open\u00a0<code>res\/layout\/main.xml<\/code>\u00a0file :<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-xml6.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3740\" alt=\"main-xml\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-xml6.jpg\" width=\"299\" height=\"513\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-xml6.jpg 299w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-xml6-174x300.jpg 174w\" sizes=\"(max-width: 299px) 100vw, 299px\" \/><\/a><\/p>\n<p>And paste the following code :<\/p>\n<pre class=\"brush:java\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    android:orientation=\"vertical\" &gt;\r\n\r\n    &lt;ProgressBar\r\n        android:id=\"@+id\/progressBar1\"\r\n        style=\"?android:attr\/progressBarStyleHorizontal\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:indeterminate=\"false\"\r\n        android:max=\"10\"\r\n        android:padding=\"4dip\" &gt;\r\n    &lt;\/ProgressBar&gt;\r\n\r\n    &lt;Button\r\n        android:id=\"@+id\/button1\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:onClick=\"startProgress\"\r\n        android:text=\"Start\" \/&gt;\r\n\r\n&lt;\/LinearLayout&gt;<\/pre>\n<p>Now you may open the Graphical layout editor to preview the User Interface you created:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/graphical-layout2.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3744\" alt=\"graphical-layout\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/graphical-layout2.jpg\" width=\"537\" height=\"503\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/graphical-layout2.jpg 537w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/graphical-layout2-300x281.jpg 300w\" sizes=\"(max-width: 537px) 100vw, 537px\" \/><\/a><\/p>\n<h3>3. Code<\/h3>\n<p>Now we have to write the code of the application. Use the Package Explorer to navigate to the Java file of the Activity you\u2019ve created:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-src-file2.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3743\" alt=\"main-src-file\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-src-file2.jpg\" width=\"449\" height=\"306\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-src-file2.jpg 449w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-src-file2-300x204.jpg 300w\" sizes=\"(max-width: 449px) 100vw, 449px\" \/><\/a><\/p>\n<p>The code of this tutorial is pretty much self\u00a0explanatory. The interesting part is how to update the value of the Progress bar. We are going to use a <code>Thread<\/code> to run the backgroud process that updates tha value of the progress bar. Although this example works fine, it is strongly advised to use a <a href=\"http:\/\/examples.javacodegeeks.com\/android\/core\/os\/handler\/android-handler-example\/\">Handler<\/a> or an <a href=\"http:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/\">AsyncTask<\/a> to explicity bind the backroud thread with the UI thread.<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.androidthreadexample;\r\n\r\nimport android.app.Activity;\r\nimport android.os.Bundle;\r\nimport android.view.View;\r\nimport android.widget.ProgressBar;\r\n\r\npublic class MainActivity extends Activity {\r\n\tprivate ProgressBar bar;\r\n\r\n\t\/** Called when the activity is first created. *\/\r\n\r\n\t@Override\r\n\tpublic void onCreate(Bundle savedInstanceState) {\r\n\t\tsuper.onCreate(savedInstanceState);\r\n\t\tsetContentView(R.layout.main);\r\n\t\tbar = (ProgressBar) findViewById(R.id.progressBar1);\r\n\r\n\t}\r\n\r\n\tpublic void startProgress(View view) {\r\n\r\n\t\tbar.setProgress(0);\r\n\t\tnew Thread(new Task()).start();\r\n\t}\r\n\r\n\tclass Task implements Runnable {\r\n\t\t@Override\r\n\t\tpublic void run() {\r\n\t\t\tfor (int i = 0; i &lt;= 10; i++) {\r\n\t\t\t\tfinal int value = i;\r\n\t\t\t\ttry {\r\n\t\t\t\t\tThread.sleep(1000);\r\n\t\t\t\t} catch (InterruptedException e) {\r\n\t\t\t\t\te.printStackTrace();\r\n\t\t\t\t}\r\n\t\t\t\tbar.setProgress(value);\r\n\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t}\r\n\r\n}<\/pre>\n<h3>4. Run the application<\/h3>\n<p>This is the main screen of our Application.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-screen11.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3745\" alt=\"main-screen\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-screen11.jpg\" width=\"256\" height=\"470\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-screen11.jpg 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-screen11-163x300.jpg 163w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>Now, when you press the \u201cStart\u201d button,\u00a0the thread that updates the bar\u2019s value :<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/progress1.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3746\" alt=\"progress\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/progress1.jpg\" width=\"256\" height=\"470\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/progress1.jpg 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/progress1-163x300.jpg 163w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<h3>Download Eclipse Project<\/h3>\n<p>This was an Android Thread Example. Download the Eclipse Project of this tutorial:\u00a0<a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/AndroidThreadExample.zip\">AndroidThreadExample<\/a><a href=\"http:\/\/cdn.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/AndroidHandlerExample.zip\"><br \/>\n<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this example we are going to see how to use Android\u00a0Thread. As we \u00a0read from the official documentation: A\u00a0Thread\u00a0is a concurrent unit of execution. It has its own call stack for methods being invoked, their arguments and local variables. Each virtual machine instance has at least one main\u00a0Thread\u00a0running when it is started; typically, there &hellip;<\/p>\n","protected":false},"author":4,"featured_media":1202,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[442],"tags":[],"class_list":["post-3736","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Android Thread Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this example we are going to see how to use Android\u00a0Thread. As we \u00a0read from the official documentation: A\u00a0Thread\u00a0is a concurrent unit of execution. It\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android Thread Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this example we are going to see how to use Android\u00a0Thread. As we \u00a0read from the official documentation: A\u00a0Thread\u00a0is a concurrent unit of execution. It\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2013-05-19T10:09:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-05-19T12:23:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Nikos Maravitsas\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nikos Maravitsas\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/\"},\"author\":{\"name\":\"Nikos Maravitsas\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/686a494fbb577a8d1231862b139cda6b\"},\"headline\":\"Android Thread Example\",\"datePublished\":\"2013-05-19T10:09:15+00:00\",\"dateModified\":\"2013-05-19T12:23:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/\"},\"wordCount\":551,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"articleSection\":[\"Thread\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/\",\"name\":\"Android Thread Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"datePublished\":\"2013-05-19T10:09:15+00:00\",\"dateModified\":\"2013-05-19T12:23:44+00:00\",\"description\":\"In this example we are going to see how to use Android\u00a0Thread. As we \u00a0read from the official documentation: A\u00a0Thread\u00a0is a concurrent unit of execution. It\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"core\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Thread\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/thread\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Android Thread Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/686a494fbb577a8d1231862b139cda6b\",\"name\":\"Nikos Maravitsas\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Nikos-Maravitsas-80x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Nikos-Maravitsas-80x96.jpg\",\"caption\":\"Nikos Maravitsas\"},\"description\":\"Nikos has graduated from the Department of Informatics and Telecommunications of The National and Kapodistrian University of Athens. During his studies he discovered his interests about software development and he has successfully completed numerous assignments in a variety of fields. Currently, his main interests are system\u2019s security, parallel systems, artificial intelligence, operating systems, system programming, telecommunications, web applications, human \u2013 machine interaction and mobile development.\",\"sameAs\":[\"http:\/\/www.javacodegeeks.com\/\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/nikos-maravitsas\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android Thread Example - Java Code Geeks","description":"In this example we are going to see how to use Android\u00a0Thread. As we \u00a0read from the official documentation: A\u00a0Thread\u00a0is a concurrent unit of execution. It","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/","og_locale":"en_US","og_type":"article","og_title":"Android Thread Example - Java Code Geeks","og_description":"In this example we are going to see how to use Android\u00a0Thread. As we \u00a0read from the official documentation: A\u00a0Thread\u00a0is a concurrent unit of execution. It","og_url":"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-05-19T10:09:15+00:00","article_modified_time":"2013-05-19T12:23:44+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","type":"image\/jpeg"}],"author":"Nikos Maravitsas","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Nikos Maravitsas","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/"},"author":{"name":"Nikos Maravitsas","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/686a494fbb577a8d1231862b139cda6b"},"headline":"Android Thread Example","datePublished":"2013-05-19T10:09:15+00:00","dateModified":"2013-05-19T12:23:44+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/"},"wordCount":551,"commentCount":1,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","articleSection":["Thread"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/","url":"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/","name":"Android Thread Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","datePublished":"2013-05-19T10:09:15+00:00","dateModified":"2013-05-19T12:23:44+00:00","description":"In this example we are going to see how to use Android\u00a0Thread. As we \u00a0read from the official documentation: A\u00a0Thread\u00a0is a concurrent unit of execution. It","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/thread\/android-thread-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Android","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/"},{"@type":"ListItem","position":3,"name":"core","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/"},{"@type":"ListItem","position":4,"name":"Thread","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/thread\/"},{"@type":"ListItem","position":5,"name":"Android Thread Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/686a494fbb577a8d1231862b139cda6b","name":"Nikos Maravitsas","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Nikos-Maravitsas-80x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Nikos-Maravitsas-80x96.jpg","caption":"Nikos Maravitsas"},"description":"Nikos has graduated from the Department of Informatics and Telecommunications of The National and Kapodistrian University of Athens. During his studies he discovered his interests about software development and he has successfully completed numerous assignments in a variety of fields. Currently, his main interests are system\u2019s security, parallel systems, artificial intelligence, operating systems, system programming, telecommunications, web applications, human \u2013 machine interaction and mobile development.","sameAs":["http:\/\/www.javacodegeeks.com\/"],"url":"https:\/\/examples.javacodegeeks.com\/author\/nikos-maravitsas\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/3736","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=3736"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/3736\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1202"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=3736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=3736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=3736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}