IT. Expert System.

Java basics

yield


The java.lang.Thread.yield() method causes the currently executing thread object to temporarily pause and allow other threads to execute.

Syntax:
public static void yield()


Example:

import java.lang.*;

public class ThreadDemo implements Runnable {

   Thread t;

   ThreadDemo(String str) {

      t = new Thread(this, str);
      // this will call run() function
      t.start();
   }

   public void run() {

      for (int i = 0; i < 5; i++) {
         // yields control to another thread every 5 iterations
            if ((i % 5) == 0) {
               system.out.println(thread.currentthread().getname() + "
               yielding control...");
               
               /* causes the currently executing thread object to temporarily 
               pause and allow other threads to execute */
               thread.yield();
            }
      }

      system.out.println(thread.currentthread().getname() + " has 
      finished executing.");
   }

   public static void main(string[] args) {
      new threaddemo("thread 1");
      new threaddemo("thread 2");
      new threaddemo("thread 3");
   }
}


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 515 / 159172406. Delta: 0.04553 с