Java 8 Method Reference example

package com.vinod.test;

public class Java8ThreadExample {
public static void main(String[] args) {
Thread t1 = new Thread(Java8ThreadExample::printJob);
Thread t2 = new Thread(Java8ThreadExample::printJob);
t1.start();
t2.start();

}
public static void printJob() {
for (int i = 1; i <= 15; i++) {
System.out.println(Thread.currentThread()+"printing" + i);
}

}
}

No comments:

Post a Comment

12 classic String-based Java interview questions with simple explanations and code.

  1️⃣ Check if a String is a Palindrome Problem Given a string, check if it reads the same forward and backward. Example: "madam...

Featured Posts