Questions tagged [thread-synchronization]

In a multi-threaded environment thread synchronization is used to coordinate access to shared resources such as file handles, network connections, and memory

In a multi-threaded environment thread synchronization is used to coordinate access to shared resources such as file handles, network connections, and memory

References

645 questions
-1
votes
1 answer

How to synchronize threads with shared data С++

I am writing a simple minecraft clone and I need help. I have a "Chunk" class that implements the "calculateMesh" and "createChunk" methods, the second method fills the chunk blocks field with a specific block type, and then the "calculateMesh"…
-1
votes
2 answers

Consumer producer multithreading freezes

I'm trying to create a simple consumer/producer code for learning, in which a producer pushes numbers into a stack, and consumer threads print the numbers, heres what I got: const int N_THREADS = 10; const int N_TESTS = 100; bool finished =…
-1
votes
1 answer

Find Process Count in Java

I am able to launch Process with the help of below command and after launching multiple processes I want to control how many processes I want to keep at some point. For example: Initiate a Process inside a for loop of range 0 to 50 Pause the for…
paul
  • 4,333
  • 16
  • 71
  • 144
-1
votes
2 answers

Fundamental question about synchronizing with the UI thread in Winforms using c#

I know Winforms has only one UI thread, and if you need to update it while you are on another thread, you should use invoke method. My questions is if what you are doing does not change the look of any control, would that still be accessing the UI…
-1
votes
1 answer

Synchronization between two lists

I have the following problem that uses java concurrency. There are 3 clients and the cooker in a restaurant. All of them change information through 2 lists. One list for placing the orders, and another list for placing the meals. The customer sends…
xeon123
  • 819
  • 1
  • 10
  • 25
-1
votes
1 answer

How to implement concurrency in Queue

I am trying to implement a queue which should be synchronized. The requirement is: If the Queue is empty and new data comes then data should be inserted in queue and data processing should start as long as queue does not become empty. If Queue is…
-1
votes
1 answer

Pthreads program with mutex - printing same string every time

I have a school project that requires me to wrote a program printing this: ….............. using 3 threads and mutex. I have tried to do it with some help of the class, but it just keeps printing…
-1
votes
2 answers

What is the difference between synchronized fields and ReadWriteLocks?

Just want to know how the below codes that does the same functionality differs Code 1: class ReadWriteCounter { ReadWriteLock lock = new ReentrantReadWriteLock(); private Integer count = 0; public Integer incrementAndGetCount() { …
-1
votes
1 answer

Java: thread able to call a method that is in synchronised block of some other thread

thread t1 is calling test1() method of Test class object ob. thread t2 is calling test1() method of Test class object ob in synchronized block. t1 is able to call test1() method of ob even though test1() method call of ob is in synchronised block…
-1
votes
1 answer

What happens if a thread is in the critical section or entering the critical section?

I am trying to better understand a chapter and have been confused about what happens if a thread is in the critical section or is entering the critical section. May someone explain or give me an idea on the process of what the thread undergoes in…
justoneday
  • 25
  • 3
-1
votes
1 answer

Consumer-Producer Problem using multi-threading

I'm pretty new to threads and just trying to get a grip on the basics.I'm trying to implement consumer-producer problem. Can anybody help me with the code. import java.util.ArrayList; import java.util.List; public class T { public static void…
-1
votes
1 answer

When is concurrent execution of two critical sections producing results in some unknown order useful?

Refer to Galvin et. al Operating System Concepts, 8th edition, 6th chapter, section 6.9, page 257. It says, "If two critical sections are instead executed concurrently, the result is equivalent to their sequential execution in some unknown order.…
-1
votes
1 answer

Thread synchronization in Linux?

I am writing a code wherein I am making my threads wait till I do a pthread_cond_broadcast. I have three threads in this code. Threads line2_thread and line3_thread, are running in the order of their priority like they are supposed to run. However,…
Moose
  • 751
  • 22
  • 42
-1
votes
2 answers

How synchronization works in online transaction

I was reading about synchronization in java and have some questions. I understand when multiple threads access same object it leads to data inconsistency. As a solution, whichever thread that own the Object's lock will execute An example I have seen…
-1
votes
1 answer

java multithreading synchronized block not working

I am not able to get why I am getting exception with both : class level lock as well as with object level lock in below code : It seems object level locking should work here as we are changing and accessing hm(Object) value using different threads,…
RVP
  • 3
  • 3