This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A | |
if ($result == 200) { | |
return true; | |
} | |
return false; | |
// B | |
return $result == 200 ? true : false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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> |