8000 GitHub - sc-aug/java-learn
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

sc-aug/java-learn

Repository files navigation

Java Practices ide: eclipse env: java 1.8.0

Java Core

File IO

Multithreading

  • code code code Thread creation
  • code volatile keyword (cpu cache / visibility of changes to variables across threads)
  • code synchronized keyword on method (join())
  • code synchronized keyword on method
  • code Unsynchronized example. 'synchronized method' not work on different objects
  • code Producer & Consumer, synchronized code block -- object lock. List size of 1
  • code Producer & Consumer, synchronized code block -- object lock. List size of N
  • code Producer & Consumer, thread save linked list
  • code Producer & Consumer, 2 threads add item to list, 2 threads remove item from list
  • code Unsynchronized Example. Lock on differet objects.
  • code 1 Chef (make food if table empty/block if customer eating) 1 Customer (eat food if food ready/block if food not ready) (Resource 1 table)
  • code class Executor, method execute(Runnable)
  • code class ExecutorService, method execute(Runnable/Callable).
  • code Sum numbers. ExecutorService / Runnable/Callable / Future
  • code CountDownLatch, Max Number
  • code CountDownLatch, Sum Numbers
  • code CyclicBarrier
  • code Dining Philosopher: DeadLock. Semaphore
  • code Dining Philosopher: Solve Deadlock, might have Starvation. Semaphore
  • [code][multi-philos02] Dining Philosopher: Solve Starvation. ReentrantLock - Fairness

Java JDBC

Java 8

Lambda Expression

  • code Java 8 interface feature: default/static method
  • code code code Simple demo of functional interface.
  • code Print the string which length <= 4 in a list.
  • code Check if the length of string is less or equal to 4 (Predicate).
  • code Print the length of a string (Function).
  • code Generate a random number (Supplier).
  • code Print the product that its price is less than 1000.0 (stream api).
  • code Print even numbers in the list (stream api).
  • code Print employees whose marks are greater than 90, sort the result by employee ID ** (stream api)**.
  • code For those who marks are less than 40, give them 5 as the grace marks and then print out the final marks and id and sort them on basis of marks (stream api).
  • code Print name of employees who are less than 25 years old and scored more than 40 marks, sort the employees based on their marks (stream api).
  • code Using stream with List, Set, Map, Array
  • code Employee class: id, name, salary. For each employee: tax on the income salary: less than 3000: 10%. 3000 and 5000: 20%. above 5000: 30% calculate the salary after tax and then find the employee with max salary.

Stream API

  • [code][stream-demo15] Stream api [.filter .distinct(need equals) .collect] TreeSet[comparable]
  • [code][stream-demo16] And then [stream-demo01]: java8/src/com/shichuan/java/streamapi/LambdaDemo01.java [stream-demo02]: java8/src/com/shichuan/java/streamapi/LambdaDemo02.java

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0