Java Thread Safety

Su Suriya Ravichandran Updated 18 Nov 2026
14 min read ·Lesson 190 of 306

Java thread safety means that a class or method keeps working correctly when many threads use it at the same time, without the callers having to add any extra locking. Code that is not thread-safe can lose updates, throw strange exceptions, or return corrupted data, but only sometimes, which makes the bugs hard to find.

Thread safety problems only appear when threads share mutable state: data that more than one thread can change. This lesson shows the main techniques for making code thread-safe, from simply not sharing data to using Java's concurrent classes.


What Breaks Java Thread Safety

Most standard classes, such as ArrayList and HashMap, are not thread-safe. They are fast because they do no locking, but they assume only one thread changes them at a time.

import java.util.ArrayList;
import java.util.List;

public class UnsafeList {
    public static void main(String[] args) throws InterruptedException {
        List<Integer> orderIds = new ArrayList<>(); // ArrayList is NOT thread-safe

        Runnable addOrders = () -> {
            for (int i = 0; i < 100_000; i++) {
                try {
                    orderIds.add(i);
                } catch (ArrayIndexOutOfBoundsException e) {
                    System.out.println(Thread.currentThread().getName() + ": " + e.getClass().getSimpleName());
                    return;
                }
            }
        };

        Thread t1 = new Thread(addOrders, "t1");
        Thread t2 = new Thread(addOrders, "t2");
        Thread t3 = new Thread(addOrders, "t3");
        t1.start(); t2.start(); t3.start();
        t1.join(); t2.join(); t3.join();

        System.out.println("expected size: 300000");
        System.out.println("actual size  : " + orderIds.size());
    }
}

Output (different on every run; sometimes an ArrayIndexOutOfBoundsException is printed too):

expected size: 300000
actual size  : 263281

How it works:

  • Three threads each add 100,000 numbers to the same ArrayList.
  • add() stores the element and then increases an internal size field. When two threads do this at the same moment, they can write into the same slot, and one element is lost.
  • If the list grows its internal array while another thread is writing, that thread can even get an ArrayIndexOutOfBoundsException.
Thread-safety techniqueIdeaExample tools
ConfinementDon't share the data at allLocal variables, ThreadLocal
ImmutabilityShare data that can't changerecord, final fields, List.of()
LockingLet one thread at a time change itsynchronized, ReentrantLock
Atomic variablesLock-free single-value updatesAtomicInteger, LongAdder
Concurrent collectionsThread-safe data structuresConcurrentHashMap, CopyOnWriteArrayList
VisibilityMake writes visible to other threadsvolatile

Locking was covered in Java Synchronization. The sections below cover the other techniques.


Thread Confinement: Don't Share the Data

The simplest way to be thread-safe is to keep data inside one thread. Local variables live on each thread's own stack, so two threads running the same method never see each other's locals.

import java.util.ArrayList;
import java.util.List;

public class Confinement {
    // No shared fields: every call works only with its own local variables
    static double cartTotal(List<Double> prices) {
        double total = 0;                    // local: each thread has its own copy
        List<String> lines = new ArrayList<>(); // created and used by one thread only
        for (double price : prices) {
            total += price;
            lines.add(String.format("%.2f", price));
        }
        return total;
    }

    public static void main(String[] args) throws InterruptedException {
        double[] results = new double[2];
        Thread customerA = new Thread(() -> results[0] = cartTotal(List.of(199.0, 49.5, 20.0)));
        Thread customerB = new Thread(() -> results[1] = cartTotal(List.of(999.0, 1.0)));
        customerA.start();
        customerB.start();
        customerA.join();
        customerB.join();

        System.out.println("customer A total: " + results[0]);
        System.out.println("customer B total: " + results[1]);
    }
}

Output:

customer A total: 268.5
customer B total: 1000.0

How it works:

  • cartTotal() has no fields; total and lines are local variables.
  • Both threads run the same method at the same time, but each has its own total and its own lines list, so there is nothing to protect.
  • Each thread writes to a different slot of results, and main reads them after join(), which makes the values visible.

Note: Confinement breaks as soon as a local object "escapes", for example when you store it in a static field or pass it to another thread. The rule is about who can reach the object, not where it was declared.


Immutable Objects Are Thread-Safe

An immutable object cannot change after it is created. Any number of threads can read it at the same time with no locking at all. In Java, a record with immutable field types is the easiest way to create one.

import java.util.List;

public class ImmutablePrice {
    // A record is immutable: final fields, no setters
    record Price(String sku, long amountPaise, String currency) {
        Price withDiscount(int percent) {
            // "Changing" an immutable object returns a NEW object
            return new Price(sku, amountPaise * (100 - percent) / 100, currency);
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Price original = new Price("HEADPHONES-01", 250_000, "INR");
        List<Integer> discounts = List.of(10, 25, 50);
        Price[] discounted = new Price[discounts.size()];

        Thread[] workers = new Thread[discounts.size()];
        for (int i = 0; i < workers.length; i++) {
            int index = i;
            // All threads read the same object; nobody can modify it
            workers[i] = new Thread(() -> discounted[index] = original.withDiscount(discounts.get(index)));
            workers[i].start();
        }
        for (Thread w : workers) w.join();

        System.out.println("original: " + original);
        for (Price p : discounted) System.out.println("new     : " + p);
    }
}

Output:

original: Price[sku=HEADPHONES-01, amountPaise=250000, currency=INR]
new     : Price[sku=HEADPHONES-01, amountPaise=225000, currency=INR]
new     : Price[sku=HEADPHONES-01, amountPaise=187500, currency=INR]
new     : Price[sku=HEADPHONES-01, amountPaise=125000, currency=INR]

How it works:

  • Price is a record, so its fields are final and it has no setters.
  • withDiscount() does not modify the object; it returns a new Price.
  • Three threads use the same original object at once, and it is still unchanged at the end.
  • Strings, LocalDate, BigDecimal and the lists made by List.of() are immutable too, which is why they can be shared freely.

Atomic Variables for Thread-Safe Counters

The classes in java.util.concurrent.atomic update a single value safely without a lock. They use special CPU instructions that read, change and write the value in one indivisible step.

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.LongAdder;

public class AtomicCounter {
    public static void main(String[] args) throws InterruptedException {
        AtomicInteger pageViews = new AtomicInteger();   // one atomic counter
        LongAdder apiCalls = new LongAdder();            // faster under heavy contention

        Runnable visitor = () -> {
            for (int i = 0; i < 250_000; i++) {
                pageViews.incrementAndGet(); // atomic read-add-write, no lock
                apiCalls.increment();
            }
        };

        Thread[] threads = new Thread[4];
        for (int i = 0; i < threads.length; i++) {
            threads[i] = new Thread(visitor);
            threads[i].start();
        }
        for (Thread t : threads) t.join();

        System.out.println("page views: " + pageViews.get());
        System.out.println("api calls : " + apiCalls.sum());
    }
}

Output:

page views: 1000000
api calls : 1000000

How it works:

  • incrementAndGet() is the atomic version of count++. Four threads add a quarter of a million each, and no update is lost.
  • LongAdder spreads the counting over several internal cells, so it is faster when many threads update it constantly. sum() adds the cells together.
  • Use AtomicInteger when you need the new value immediately (like generating IDs), and LongAdder for statistics that are read now and then.

Thread-Safe Collections in Java

The java.util.concurrent package offers collections built for multithreaded use. The older Collections.synchronizedList() wrapper also works, by locking every method.

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;

public class SafeCollections {
    public static void main(String[] args) throws InterruptedException {
        List<Integer> syncList = Collections.synchronizedList(new ArrayList<>());
        List<Integer> cowList = new CopyOnWriteArrayList<>();
        Map<String, Integer> salesByCity = new ConcurrentHashMap<>();
        String[] cities = {"Chennai", "Mumbai", "Delhi"};

        Runnable task = () -> {
            for (int i = 0; i < 3_000; i++) {
                syncList.add(i);
                if (i % 100 == 0) cowList.add(i);             // fewer writes: copy-on-write is costly
                salesByCity.merge(cities[i % 3], 1, Integer::sum); // atomic update per key
            }
        };

        Thread t1 = new Thread(task);
        Thread t2 = new Thread(task);
        Thread t3 = new Thread(task);
        t1.start(); t2.start(); t3.start();
        t1.join(); t2.join(); t3.join();

        System.out.println("synchronizedList size: " + syncList.size());
        System.out.println("CopyOnWriteArrayList : " + cowList.size());
        System.out.println("sales by city        : " + new java.util.TreeMap<>(salesByCity));
    }
}

Output:

synchronizedList size: 9000
CopyOnWriteArrayList : 90
sales by city        : {Chennai=3000, Delhi=3000, Mumbai=3000}

How it works:

  • Collections.synchronizedList() wraps an ArrayList and locks it for each call, so all 9000 additions are kept.
  • CopyOnWriteArrayList copies its internal array on every write. Writes are slow, but reads need no locking, which suits lists that are read often and changed rarely, such as a list of listeners.
  • ConcurrentHashMap.merge() updates the count for a key atomically, so no sale is lost even though three threads update the same three keys.
CollectionThread-safe?Best for
ArrayList, HashMap, HashSetNoOne thread, or data that is never changed after setup
Collections.synchronizedList/MapYes, one lock for everythingSimple cases with low traffic
ConcurrentHashMapYes, fine-grainedShared maps and caches
CopyOnWriteArrayListYesMany reads, very few writes
ConcurrentLinkedQueue, ArrayBlockingQueueYesPassing work between threads

Check-Then-Act: Thread-Safe Classes Can Still Be Misused

Using a thread-safe collection does not make combinations of calls safe. "Check if the key is missing, then put it" is two separate calls, and another thread can act between them.

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;

public class CheckThenAct {
    static final AtomicInteger expensiveLoads = new AtomicInteger();

    static String loadProfile(String userId) {
        expensiveLoads.incrementAndGet(); // count how often the slow load runs
        try {
            Thread.sleep(50); // simulate a database call
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
        return "Profile of " + userId;
    }

    static void run(String label, Map<String, String> cache, boolean atomic) throws InterruptedException {
        expensiveLoads.set(0);
        CountDownLatch startSignal = new CountDownLatch(1);
        Thread[] requests = new Thread[8];
        for (int i = 0; i < requests.length; i++) {
            requests[i] = new Thread(() -> {
                try {
                    startSignal.await(); // all threads start at the same moment
                } catch (InterruptedException e) {
                    return;
                }
                if (atomic) {
                    cache.computeIfAbsent("u42", CheckThenAct::loadProfile);
                } else {
                    if (!cache.containsKey("u42")) {          // check...
                        cache.put("u42", loadProfile("u42")); // ...then act: two separate steps
                    }
                }
            });
            requests[i].start();
        }
        startSignal.countDown();
        for (Thread r : requests) r.join();
        System.out.println(label + " -> profile loaded " + expensiveLoads.get() + " time(s)");
    }

    public static void main(String[] args) throws InterruptedException {
        run("containsKey + put  ", new ConcurrentHashMap<>(), false);
        run("computeIfAbsent    ", new ConcurrentHashMap<>(), true);
    }
}

Output:

containsKey + put   -> profile loaded 8 time(s)
computeIfAbsent     -> profile loaded 1 time(s)

How it works:

  • A CountDownLatch releases all eight request threads at the same moment.
  • With containsKey() followed by put(), every thread checks before any thread has stored the profile, so all eight run the slow database load.
  • computeIfAbsent() does the check and the insert as one atomic step for that key. Only the first thread runs loadProfile; the others wait and receive the stored value.
  • The same problem exists with if (counter.get() < limit) counter.incrementAndGet();. Prefer single methods that do the whole job, such as compute, merge, putIfAbsent or compareAndSet.

The volatile Keyword for Visibility

Each thread may keep its own cached copy of a variable for speed. Without synchronization, a change made by one thread might never be seen by another. Marking a field volatile guarantees that every read sees the most recent write.

public class VolatileFlag {
    // volatile: every read sees the latest write from any thread
    private static volatile boolean running = true;

    public static void main(String[] args) throws InterruptedException {
        Thread heartbeat = new Thread(() -> {
            long beats = 0;
            while (running) {          // re-reads the field on every loop
                beats++;
            }
            System.out.println("heartbeat: stopped after seeing running = false");
        }, "heartbeat");

        heartbeat.start();
        Thread.sleep(500);
        running = false;               // this write becomes visible to heartbeat
        heartbeat.join(2000);
        System.out.println("main: heartbeat alive? " + heartbeat.isAlive());
    }
}

Output:

heartbeat: stopped after seeing running = false
main: heartbeat alive? false

How it works:

  • heartbeat loops while running is true. main sets it to false after 500 ms.
  • Because running is volatile, heartbeat reads the real current value on each loop and stops. Without volatile, the JIT compiler is allowed to read the field once and loop forever.
  • volatile guarantees visibility, not atomicity: volatileCount++ is still unsafe. Use it for simple flags and for publishing a reference that is written by one thread.

Thread-Safe and Unsafe JDK Classes

Some JDK classes look harmless but are not thread-safe, because they keep changing internal state while they work. Sharing one instance between threads gives wrong results or exceptions; the usual fix is a thread-safe alternative or one instance per thread.

Not thread-safeThread-safe alternative
SimpleDateFormatDateTimeFormatter (immutable)
StringBuilder (when shared)Local StringBuilder per thread, or StringBuffer
HashMapConcurrentHashMap
Random (shared, slow under contention)ThreadLocalRandom.current()
NumberFormat, DecimalFormatOne instance per thread (ThreadLocal)

Giving Each Thread Its Own Copy with ThreadLocal

When a class is not thread-safe but expensive to create, ThreadLocal gives every thread its own instance. That is thread confinement handled for you.

import java.text.NumberFormat;
import java.util.Locale;

public class ThreadLocalDemo {
    // Each thread gets its own NumberFormat instance (NumberFormat is not thread-safe)
    private static final ThreadLocal<NumberFormat> RUPEES =
            ThreadLocal.withInitial(() -> NumberFormat.getCurrencyInstance(Locale.of("en", "IN")));

    public static void main(String[] args) throws InterruptedException {
        NumberFormat[] seen = new NumberFormat[2];

        Thread a = new Thread(() -> {
            seen[0] = RUPEES.get(); // created on the first get() in this thread
            System.out.println("invoice-a: " + seen[0].format(123456.5));
            System.out.println("invoice-a: same instance on second get()? " + (RUPEES.get() == seen[0]));
        }, "invoice-a");

        Thread b = new Thread(() -> {
            seen[1] = RUPEES.get(); // a separate instance for this thread
            System.out.println("invoice-b: " + seen[1].format(999.0));
        }, "invoice-b");

        a.start(); a.join();
        b.start(); b.join();
        System.out.println("threads share one formatter? " + (seen[0] == seen[1]));
    }
}

Output:

invoice-a: ₹123,456.50
invoice-a: same instance on second get()? true
invoice-b: ₹999.00
threads share one formatter? false

How it works:

  • ThreadLocal.withInitial() creates a new NumberFormat the first time each thread calls get().
  • Within one thread, get() always returns the same instance; different threads get different instances, so they can never interfere.
  • In thread pools, threads are reused for many tasks. Call RUPEES.remove() when a task's per-thread data must not leak into the next task.

Real-World Example: A Thread-Safe Inventory Service

This inventory service combines several techniques: immutable products, an unchangeable catalog map, an atomic stock update per product, an atomic order counter, a LongAdder for revenue and a concurrent list for alerts. Eight customer threads order at the same time, and the stock must never go below zero.

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.LongAdder;

public class InventoryService {

    // Immutable value object: safe to share between threads
    record Product(String sku, String name, long pricePaise) { }

    // Immutable result object
    record OrderResult(String orderId, boolean accepted, String reason) { }

    private final Map<String, Product> catalog;                       // never changed after construction
    private final ConcurrentHashMap<String, Integer> stock = new ConcurrentHashMap<>();
    private final AtomicInteger orderSequence = new AtomicInteger(1000);
    private final LongAdder revenuePaise = new LongAdder();
    private final List<String> soldOutAlerts = new CopyOnWriteArrayList<>();

    InventoryService(List<Product> products, int initialStock) {
        catalog = Map.copyOf(products.stream()
                .collect(java.util.stream.Collectors.toMap(Product::sku, p -> p)));
        for (Product p : products) {
            stock.put(p.sku(), initialStock);
        }
    }

    OrderResult placeOrder(String sku, int quantity) {
        String orderId = "ORD-" + orderSequence.incrementAndGet();
        Product product = catalog.get(sku);
        if (product == null) {
            return new OrderResult(orderId, false, "unknown product");
        }

        boolean[] reserved = {false};
        // compute() runs atomically for this key: check and update happen together
        stock.compute(sku, (key, available) -> {
            if (available >= quantity) {
                reserved[0] = true;
                int left = available - quantity;
                if (left == 0) soldOutAlerts.add(key);
                return left;
            }
            return available; // not enough stock: keep the value unchanged
        });

        if (!reserved[0]) {
            return new OrderResult(orderId, false, "out of stock");
        }
        revenuePaise.add(product.pricePaise() * quantity);
        return new OrderResult(orderId, true, "ok");
    }

    public static void main(String[] args) throws InterruptedException {
        InventoryService shop = new InventoryService(List.of(
                new Product("PHONE", "Smartphone", 1_500_000),
                new Product("CASE", "Phone case", 50_000)), 100);

        LongAdder accepted = new LongAdder();
        LongAdder rejected = new LongAdder();

        Thread[] customers = new Thread[8];
        for (int c = 0; c < customers.length; c++) {
            customers[c] = new Thread(() -> {
                for (int i = 0; i < 30; i++) {
                    String sku = (i % 2 == 0) ? "PHONE" : "CASE";
                    OrderResult result = shop.placeOrder(sku, 1);
                    if (result.accepted()) accepted.increment(); else rejected.increment();
                }
            });
            customers[c].start();
        }
        for (Thread customer : customers) customer.join();

        System.out.println("orders accepted : " + accepted.sum());
        System.out.println("orders rejected : " + rejected.sum());
        System.out.println("stock left      : " + new java.util.TreeMap<>(shop.stock));
        System.out.println("sold-out alerts : " + shop.soldOutAlerts);
        System.out.printf("revenue         : Rs. %,.2f%n", shop.revenuePaise.sum() / 100.0);
        System.out.println("last order id   : ORD-" + shop.orderSequence.get());
    }
}

Output:

orders accepted : 200
orders rejected : 40
stock left      : {CASE=0, PHONE=0}
sold-out alerts : [PHONE, CASE]
revenue         : Rs. 1,550,000.00
last order id   : ORD-1240

How it works:

  1. Immutable data. Product and OrderResult are records, and catalog is created with Map.copyOf(), so it can be read by all threads with no locking.
  2. Atomic stock check. stock.compute(sku, ...) checks the available quantity and stores the new quantity in one atomic step for that product. Two customers can never both take the last phone.
  3. Unique order IDs. AtomicInteger.incrementAndGet() gives every order a different number, from ORD-1001 to ORD-1240.
  4. Revenue and alerts. LongAdder adds up revenue from many threads cheaply, and CopyOnWriteArrayList collects the rarely written sold-out alerts. The sold-out order (PHONE or CASE first) can differ between runs.
  5. The proof. 8 customers × 30 orders = 240 orders. Exactly 200 are accepted (100 phones + 100 cases), 40 are rejected as out of stock, the stock ends at exactly 0, and the revenue is 100 × Rs. 15,000 + 100 × Rs. 500 = Rs. 1,550,000.

To see how the customer threads are started and awaited, revisit Java Thread Join and Java Runnable Interface.

0 Comments

Reviewed before they appear

No comments yet.

Java
Java Introduction Java Features Java Syntax Java Comments Java Statements Java Output Java Variables Java Data Types Java Type Casting Java Operators Java Strings Java Numbers Java Math Java Booleans Java User Input Java Conditions Java If Else Java Switch Java While Loop Java For Loop Java Break Java Continue Java Arrays Java Methods Java Parameters Java Return Values Java Scope Java Recursion Install Java Install JDK Java IDEs Java JDK Java JRE Java JVM Java Compiler Java File Compile Java Run Java JShell Basics Java Packages Java OOP Java Classes Java Objects Class Methods Constructors Constructor Overload this Keyword static Keyword final Keyword Encapsulation Inheritance Polymorphism Abstraction Access Modifiers super Keyword Method Overload Method Override Instanceof Operator Nested Classes Inner Classes Anonymous Classes Enums Records Array Basics Array Length Loop Arrays Multidimensional Arrays Array Copy Array Sorting Array Search ArrayList LinkedList HashSet TreeSet HashMap TreeMap Queue Interface Deque Interface Stack Class Iterator List Interface Set Interface Map Interface Collections Class Comparable Comparator Generics Basics Generic Classes Generic Methods Wildcards String Basics String Length String Methods String Concatenation String Compare String Search String Replace String Split String Format StringBuilder StringBuffer Text Blocks Regular Expressions Number Types Integer Class Float Class Double Class BigInteger BigDecimal Math Class Random Numbers Number Format Date Basics LocalDate LocalTime LocalDateTime ZonedDateTime Date Formatting Date Parsing Period Class Duration Class Java Instant Class Java Exception Basics Java try...catch Java Multiple Catch Blocks Java finally Block Java throw Keyword Java throws Keyword Java Checked Exceptions Java Unchecked Exceptions Java Custom Exceptions Java try-with-resources Java Exception Chaining Java File Basics Java Create Files Java Read Files Java Write Files Java Delete Files Java File Paths Java File Class Java BufferedReader Java BufferedWriter Java FileInputStream Java FileOutputStream Java Object Streams Java Directory Handling Java NIO Basics Java Files API Java Input Java Scanner Class Java Console Input Java PrintStream Java InputStream Java OutputStream Java Reader Class Java Writer Class Java Buffered Streams Java Data Streams Java Generics Introduction Java Generic Types Java Generic Methods Java Bounded Types Java Wildcards Java Type Erasure Java Generic Interfaces Java Generic Collections Java Lambda Basics Java Lambda Syntax Java Functional Interfaces Java Method References Java Stream API Java Stream Creation Java Stream Filter Java Stream Map Java Stream Reduce Java Stream Sort Java Stream Collect Java Collectors Class Java Optional Class Java Parallel Streams Java Threads: Thread Basics Create a Thread in Java Java Thread Class Java Runnable Interface Java Thread States Java Thread Sleep Java Thread Join Java Thread Priority Java Synchronization Java Thread Safety Java Race Conditions Java Deadlocks Java Executor Service Java Thread Pools Java Callable Interface Java Future Interface Java CompletableFuture Java Concurrent Collections Java Atomic Classes Java Virtual Threads Java Networking Basics Java URL Class Java URI Class Java HttpClient Java HTTP Requests Java HTTP Responses Java Socket Basics Java ServerSocket Java DatagramSocket Java WebSocket Basics Java JDBC Basics Java JDBC Setup Java Database Connection Java JDBC Connection Interface Java JDBC Statement Java PreparedStatement Java ResultSet Java JDBC CRUD Operations Java JDBC Transactions Java JDBC Batch Update Java Connection Pooling with HikariCP Java JPA Basics: Entities, EntityManager and JPQL Java Hibernate Basics: SessionFactory, Session and HQL Package in Java: Basics Explained with Examples Create Package in Java: Step-by-Step Guide with Examples Import Package in Java: The import Statement Explained Access Control in Java: Packages, Classes and Members JAR File in Java: Create, Run and Inspect JAR Files Java Modules: Introduction to the Java Module System module-info in Java: Every Module Directive Explained Java Module Path: How --module-path Finds Your Modules Java Classpath: How -cp and CLASSPATH Find Your Classes Java Annotations: Basics of @ Metadata in Java Java Built-in Annotations: @Override, @Deprecated and More Java Custom Annotations: Create Your Own @interface Java Annotation Targets: @Target and ElementType Explained Java Reflection API: Inspect and Use Classes at Runtime Java Class Metadata: Names, Modifiers, Hierarchy and Generic Java Dynamic Objects: Create Objects Dynamically With Reflec Java Dynamic Proxy: Intercept Method Calls With Proxy and In Java Security Java Secure Coding Java Password Hashing Java Input Validation Java Cryptography Basics Java KeyStore Basics Java TLS Basics Java SecureRandom Java JUnit Basics Java JUnit Test Methods JUnit Assertions JUnit Test Fixtures JUnit Parameterized Tests Mockito in Java Java Mock Objects Java Integration Testing Java Code Coverage Maven in Java Create a Maven Project in Java Maven Dependencies Maven Plugins Gradle in Java Gradle Build Gradle Dependencies Build Executable JAR in Java Build WAR File in Java HTTP Basics in Java Java Servlet Basics Servlet Lifecycle in Java HttpServletRequest in Java HttpServletResponse in Java JSP in Java JSTL in JSP REST API in Java JSON in Java Java Web Application Spring Framework Basics Spring Boot Tutorial Spring MVC Spring Data JPA Spring Security Spring Boot REST API Jakarta EE Basics Java Deployment JAR Deployment Java WAR Deployment Run Java as a Service Docker Java: Dockerize a Java Application Java Environment Variables and Configuration Java Logging Basics Java Production Setup Java JVM Options Java JVM Monitoring Java Hello World App Java Calculator App Java Number Guess Game Java Student Manager Java Library System Java Bank App Java Todo App Java File Manager Java Quiz App Java REST API Project Java Chat Server Java Employee Manager Java E-commerce API
Ask about this post
AI Ask about this post

Ask questions about Java Thread Safety and get answers drawn from it.

Signed-in readers only.