Skip to content

Instantly share code, notes, and snippets.

View rokon12's full-sized avatar
🎯
Focusing

A N M Bazlur Rahman rokon12

🎯
Focusing
View GitHub Profile
package threads;
public class MyRunnable implements Runnable {
@Override
public void run() {
System.out.println("Inside run method");
System.out.println("Doing some important work concurrently");
System.out.println("sleep for a while.");
try {
package threads;
public class ThreadDemo {
public static void main(String[] args) {
Thread t1 = new MyThread();
Thread t2 = new MyThread();
t1.start();
t2.start();
package threads;
public class MyThread extends Thread {
@Override
public void run() {
for (int i = 0; i < 10; i++) {
System.out.println(i);
try {
package file;
public class Main {
public static void main(String[] args) {
Copier copier = new Copier();
copier.copy("hello.txt", "hello-copied1.txt");
Copier2 copier2 = new Copier2();
copier2.copy("hello.txt", "hello-copied2.txt");
package file;
public class Main {
public static void main(String[] args) {
Copier copier = new Copier();
copier.copy("hello.txt", "hello-copied1.txt");
Copier2 copier2 = new Copier2();
package file;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
public class Copier3 {
public void copy(String src, String dest) {
package file;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class Copier2 {
public void copy(String from, String to) {
Path src = Paths.get(from);
package file;
import java.io.*;
public class Copier {
public void copy(String src, String dest) {
File sourceFile = new File(src);
if (!sourceFile.exists()) {
package file;
import java.io.*;
public class Copier {
public void copy(String src, String dest) {
File sourceFile = new File(src);
if (!sourceFile.exists()) {
public class Reluctant {
private Reluctant reluctant = new Reluctant();
public Reluctant() throws Exception {
throw new Exception("I'm not coming out");
}
public static void main(String[] args) {
try {