Skip to content

Instantly share code, notes, and snippets.

View OMGZui's full-sized avatar
:octocat:
Focusing

omgzui OMGZui

:octocat:
Focusing
  • DXY
  • HangZhou, China
View GitHub Profile
@OMGZui
OMGZui / 6.php
Last active June 27, 2022 08:01
// A
if ($result == 200) {
return true;
}
return false;
// B
return $result == 200 ? true : false;
class SyncThread implements Runnable {
@Override
public void run() {
System.out.println(Thread.currentThread().getName() + "_Sync: " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
synchronized (new SyncThread()) {
try {
System.out.println(Thread.currentThread().getName() + "_Sync_Start: " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
Thread.sleep(2000);
System.out.println(Thread.currentThread().getName() + "_Sync_End: " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
F_thread4_Sync: 23:13:06
F_thread2_Sync: 23:13:06
F_thread3_Sync: 23:13:06
F_thread4_Sync_Start: 23:13:06
F_thread1_Sync: 23:13:06
F_thread3_Sync_Start: 23:13:06
F_thread2_Sync_Start: 23:13:06
F_thread1_Sync_Start: 23:13:06
F_thread2_Sync_End: 23:13:08
F_thread3_Sync_End: 23:13:08
class SyncThread implements Runnable {
@Override
public void run() {
System.out.println(Thread.currentThread().getName() + "_Sync: " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
synchronized (SyncThread.class) {
try {
System.out.println(Thread.currentThread().getName() + "_Sync_Start: " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
Thread.sleep(2000);
System.out.println(Thread.currentThread().getName() + "_Sync_End: " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
public class medium01Test{
public static void main(String[] args) {
SyncThread syncThread = new SyncThread();
Thread F_thread1 = new Thread(new SyncThread(), "F_thread1");
Thread F_thread2 = new Thread(new SyncThread(), "F_thread2");
Thread F_thread3 = new Thread(syncThread, "F_thread3");
Thread F_thread4 = new Thread(syncThread, "F_thread4");
F_thread1.start();
F_thread2.start();
public class medium01Test{
public static void main(String[] args) {
SyncThread syncThread = new SyncThread();
Thread F_thread1 = new Thread(new SyncThread(), "F_thread1");
Thread F_thread2 = new Thread(new SyncThread(), "F_thread2");
Thread F_thread3 = new Thread(syncThread, "F_thread3");
Thread F_thread4 = new Thread(syncThread, "F_thread4");
F_thread1.start();
F_thread2.start();
class SyncThread implements Runnable {
@Override
public void run() {
System.out.println(Thread.currentThread().getName() + "_Sync: " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
synchronized (this) {
try {
System.out.println(Thread.currentThread().getName() + "_Sync_Start: " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
Thread.sleep(2000);
System.out.println(Thread.currentThread().getName() + "_Sync_End: " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
class SyncThread implements Runnable {
@Override
public void run() {
sync();
}
public synchronized void sync() {
System.out.println(Thread.currentThread().getName() + "_Sync: " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
try {
System.out.println(Thread.currentThread().getName() + "_Sync_Start: " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
class SyncThread implements Runnable {
@Override
public void run() {
sync();
}
public synchronized static void sync() {
System.out.println(Thread.currentThread().getName() + "_Sync: " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
try {
System.out.println(Thread.currentThread().getName() + "_Sync_Start: " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
// about page
import React from 'react';
export default () => {
console.log('this is about page');
return <>
<table border="1">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>