yield() メソッドは、Thread クラスの static メソッドであり、現在の実行スレッドにアクセスし、同じ優先順位の待機中の他のスレッドにチャンスを与えます。 待機中のスレッドがない場合、または待機中のすべてのスレッドが 低優先度 の場合、同じスレッドが実行を継続します。 yield() このメソッドの利点は、待機中の他のスレッドを実行できる可能性があることです。そのため、現在のスレッドの実行にさらに時間が必要な場合は、プロセッサを他のスレッドに割り当てます。
構文
public static void yield()
例
class MyThread extends Thread { public void run() { for (int i = 0; i < 5; ++i) { Thread.yield(); // By calling this method, MyThread stop its execution and giving a chance to a main thread System.out.println("Thread started:" + Thread.currentThread().getName()); } System.out.println("Thread ended:" + Thread.currentThread().getName()); } } public class YieldMethodTest { public static void main(String[] args) { MyThread thread = new MyThread(); <strong> </strong>thread.start();<strong> </strong> for (int i = 0; i < 5; ++i) { System.out.println("Thread started:" + Thread.currentThread().getName()); } System.out.println("Thread ended:" + Thread.currentThread().getName()); } }
出力
Thread started:main Thread started:Thread-0 Thread started:main Thread started:Thread-0 Thread started:main Thread started:Thread-0 Thread started:main Thread started:Thread-0 Thread started:main Thread started:Thread-0 Thread ended:main Thread ended:Thread-0
以上がJavaにおけるyield()メソッドの重要性は何ですか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

さまざまなオペレーティングシステムでのJavaのパフォーマンスには微妙な違いがあります。 1)JVMの実装は、パフォーマンスとゴミ収集に影響を与えるHotspotやOpenJDKなど、異なります。 2)ファイルシステム構造とパスセパレーターは異なるため、Java標準ライブラリを使用して処理する必要があります。 3)ネットワークプロトコルの差動実装は、ネットワークパフォーマンスに影響します。 4)GUIコンポーネントの外観と動作は、システムによって異なります。標準のライブラリと仮想マシンテストを使用することにより、これらの違いの影響を減らし、Javaプログラムをスムーズに実行できるようにすることができます。

JavaOffersObustObject-OrientedProgramming(OOP)andTop-notchsecurityfeatures.1)oopinjavaincludesclasses、オブジェクト、継承、多型、老coluste、および有効化の有効化

javascriptandjavavedistStrenctsss:javascriptexcelsindynamictypingandasynchronousprogramming、whilejavaisrobustwithstrongopandtyping.1)javascript'sdynamicnatureallowsforrapiddeddevermentand developmentandprototyping、

JavaachievesplatformindependencethroughtheJavaVirtualMachine(JVM)andbytecode.1)TheJVMinterpretsbytecode,allowingthesamecodetorunonanyplatformwithaJVM.2)BytecodeiscompiledfromJavasourcecodeandisplatform-independent.However,limitationsincludepotentialp

java'splatformentencemeansemeansapplicationscanrunonanyplatformwithajvm、「writeonce、runany hwhere。」

jvm'sperformanceiscompetitivewitherruntimes、sped、safety、andproductivityの提供

javaachievesplatformedentenceTheThejavavirtualMachine(JVM)、avainwithcodetorunonanyplatformwithajvm.1)codescompiledintobytecode、notmachine-specificcode.2)

thejvmisanabstractcomputingMachineCrucialForrunningJavaProgramsDuetoitsPlatForm-IndopentInterChitecture.Itincludes:1)ClassLoaderForloadingClasses、2)Runtimedataareaforforforatastorage、3)executionEngineWithinterter、Jitcompiler、およびGarbagecolfecolfecolfececolfecolfer


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

ZendStudio 13.5.1 Mac
強力な PHP 統合開発環境

SecLists
SecLists は、セキュリティ テスターの究極の相棒です。これは、セキュリティ評価中に頻繁に使用されるさまざまな種類のリストを 1 か所にまとめたものです。 SecLists は、セキュリティ テスターが必要とする可能性のあるすべてのリストを便利に提供することで、セキュリティ テストをより効率的かつ生産的にするのに役立ちます。リストの種類には、ユーザー名、パスワード、URL、ファジング ペイロード、機密データ パターン、Web シェルなどが含まれます。テスターはこのリポジトリを新しいテスト マシンにプルするだけで、必要なあらゆる種類のリストにアクセスできるようになります。

AtomエディタMac版ダウンロード
最も人気のあるオープンソースエディター

MinGW - Minimalist GNU for Windows
このプロジェクトは osdn.net/projects/mingw に移行中です。引き続きそこでフォローしていただけます。 MinGW: GNU Compiler Collection (GCC) のネイティブ Windows ポートであり、ネイティブ Windows アプリケーションを構築するための自由に配布可能なインポート ライブラリとヘッダー ファイルであり、C99 機能をサポートする MSVC ランタイムの拡張機能が含まれています。すべての MinGW ソフトウェアは 64 ビット Windows プラットフォームで実行できます。

MantisBT
Mantis は、製品の欠陥追跡を支援するために設計された、導入が簡単な Web ベースの欠陥追跡ツールです。 PHP、MySQL、Web サーバーが必要です。デモおよびホスティング サービスをチェックしてください。
