forked from btpka3/btpka3.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathU.java
More file actions
48 lines (38 loc) · 1.21 KB
/
U.java
File metadata and controls
48 lines (38 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package me.test.rxjava;
import io.reactivex.*;
import io.reactivex.schedulers.*;
import java.time.*;
import java.time.format.*;
import java.util.concurrent.*;
/**
* Created by zll on 02/09/2017.
*/
public class U {
public static String now() {
ZonedDateTime zdt = ZonedDateTime.now();
return zdt.format(DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss.SSS z"));
}
public static void print(String step, Object data) {
System.out.printf("[%s][%4d - %30s] - %10s : %s%n",
now(),
Thread.currentThread().getId(),
Thread.currentThread().getName(),
step,
data
);
}
public static class MyThreadFactory implements ThreadFactory {
private int i = 0;
private String threadName = "";
public MyThreadFactory(String threadName) {
this.threadName = threadName;
}
@Override
public Thread newThread(Runnable r) {
return new Thread(r, threadName + "-" + (i++));
}
}
public static Scheduler getNamedScheduler(String name) {
return Schedulers.from(Executors.newCachedThreadPool(new MyThreadFactory(name)));
}
}