48248

Difference between Thread.Sleep(period) and Thread.CurrentThread.Join(period) [duplicate]

Question:

This question already has an answer here:

<ul><li> <a href="/questions/17072576/when-does-thread-currentthread-join-make-sense" dir="ltr" rel="nofollow">When does Thread.CurrentThread.Join() make sense?</a> <span class="question-originals-answer-count"> 4 answers </span> </li> </ul>

Somebody could explain to me what is exactly the difference between Thread.Sleep(period) and Thread.CurrentThread.Join(period)?

Answer1:

Well, Thread.Sleep blocks the thread for a specific amount of time while Thread.Join blocks it until the target thread has terminated.

Considering that Thread.CurrentThread is not going to be terminated while it's suspended (even if it is terminated externally that makes no difference because it's dead), the end result is going to be the same. However, using Join is confusing while Sleep is obvious. Deciding which one to use is no contest.

Recommend

  • How do I embed a browser in an Excel VBA form?
  • Cordova build windows on Windows 10 and VisualStudio 2017
  • How to change type datatable column [duplicate]
  • Can an Entity access a Repository?
  • Encoding special characters in xml
  • How to know when bluetooth disconnected
  • R: Hide dummies output
  • Monkey patching ActiveResource::Errors
  • Insertion Sort in C#
  • Signature method in Inspect module for python 2
  • Action Bar in API Level > 3.0 but Still Support API < 3.0
  • Use of x`apply` to speed up loops
  • Weekday as String to number
  • 3 transitions, pausetime between transitions
  • View.layout() works until next UI update
  • When to use MSAL AcquireTokenSilentAsync
  • NodeJS - installing local module
  • Semi-local Levenshtein distance
  • remove date from DateTimePicker for Compact Framework
  • CABasicAnimation creates empty default value copy of CALayer
  • ggplot2 facet_grid with distinct x-axis labels using facet_grid
  • Avoiding duplicated data in same table with jquery
  • Android NDK refer to external libraries in JNI
  • Python tk scrollbar becomes inactive once text is outside the screen
  • Ways of filling 10 places with number from [1..10] such that digit at ith place has value atmost 1 m
  • Validating a Firebase Key [duplicate]
  • watir webdriver - window not found
  • SyntaxError: expected expression, got '.'
  • Using loops in Jasmine (with injected service)
  • How to search for a method or variable name within android project?
  • Smarter Removing Unnecessary WhiteSpace CSV
  • Adding native code to an existing Worklight hybrid app
  • How to control xtics in gnuplot
  • Java Collections.shuffle() weird behaviour [closed]
  • How to use AJAX to upload large CSV file? [closed]
  • Ajax call on Multiple selection in Select box
  • how to read to huge file into buffer
  • Typeahead.js does give me suggestions but doesn't select them
  • how to get the location(lat/lng) on google maps v3 from the location(x,y)
  • Send array to next viewcontroller iOs xcode [duplicate]