Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

race-condition

Why does code mutating a shared variable across threads apparently NOT suffer from a race condition?

December 30, 2022 by Tarik

foo() is so short that each thread probably finishes before the next one even gets spawned. If you add a sleep for a random time in foo() before the u++, you may start seeing what you expect.

Categories c++ Tags c++, race-condition Leave a comment

How to get last inserted row ID from WordPress database?

December 18, 2022 by Tarik

Straight after the $wpdb->insert() that does the insert, do this: $lastid = $wpdb->insert_id; More information about how to do things the WordPress way can be found in the WordPress codex. The details above were found here on the wpdb class page

Categories wordpress Tags auto-increment, race-condition, wordpress Leave a comment

Is the != check thread safe?

November 30, 2022 by Tarik

In the absence of synchronization this code Object a; public boolean test() { return a != a; } may produce true. This is the bytecode for test() ALOAD 0 GETFIELD test/Test1.a : Ljava/lang/Object; ALOAD 0 GETFIELD test/Test1.a : Ljava/lang/Object; IF_ACMPEQ L1 … as we can see it loads field a to local vars twice, it’s … Read more

Categories java Tags atomic, java, multithreading, race-condition, thread-safety Leave a comment

What is a race condition?

August 30, 2022 by Tarik

A race condition occurs when two or more threads can access shared data and they try to change it at the same time. Because the thread scheduling algorithm can swap between threads at any time, you don’t know the order in which the threads will attempt to access the shared data. Therefore, the result of … Read more

Categories multithreading Tags concurrency, multithreading, race-condition, terminology Leave a comment
Newer posts
← Previous Page1 Page2 Page3

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa