@@ -0,0 +1,10 @@
+public class Main {
+ public static void main (String argv[]) {
+ Thread tA, tB;
+ tA = new DispTask(false, "tA");
+ tB = new DispTask(false, "tB");
+
+ tA.start();
+ tB.start();
+ }
+}
@@ -0,0 +1,18 @@
+class DispTask extends Thread {
+ boolean doYield;
+ String mark;
+ DispTask(boolean _doYield, String _mark) {
+ doYield = _doYield;
+ mark = _mark;
+ public void run() {
+ for (int i = 0; i < 10; i++) {
+ System.out.println(i + ">" + mark);
+ if (doYield)
+ yield();