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
0
votes
2 answers

Run two thread concurrently

I am trying two print two thread's name concurrently. Can any body suggest , what i am doing wrong? I am getting "IllegalMonitorStateException //ODD THREAD RUNNABLE public class OddThread implements Runnable { MainClass obj; public…
0
votes
1 answer

Java field synchronization

I am familiar with the synchronized block/method. Is this required when modifying fields from separate threads? Will setting and getting the field without synchronization at the same time cause the field to get screwed up? Here is a little…
0
votes
2 answers

Thread wait() affects the Main thread ?

Consider this simple try for a multithreading example : public class LetsMutexThreads { public static Object MUTEX = new Object(); private static class Thread1 extends Thread { public void run() { synchronized (MUTEX)…
JAN
  • 21,236
  • 66
  • 181
  • 318
0
votes
0 answers

How can I use Monitor.Pulse to pulse a thread to the front of the ready queue instead of the back?

I'm implementing a resource manager class for my application that should handle multiple threads. The requirement for this manager is that it will be given a class and a limit of instances it will be allowed to create of that class, and threads will…
Eduardo Wada
  • 2,606
  • 19
  • 31
0
votes
1 answer

Hold HTTP servlet request threads for reloading business config object

I need to Hot load or Reload business configuration / object at runtime in http servlet. Config object is generated by reading a file during servlet init(). I need to reload this object when file is changed / updated.. public void init() { …
Xavier DSouza
  • 2,861
  • 7
  • 29
  • 40
0
votes
0 answers

C++/Boost thread IPC/Flag checking

All. I'm novice in boost synchronization, so will be grateful for some critic of code below. It is ok to use it in multi-threaded environment ? Few threads just wait until My_boost_event::is_siagnaled() return true . "Controller" thread just…
user1503944
  • 387
  • 2
  • 16
0
votes
1 answer

synchronizationLockException object is not synchronised - parse login issue

I am getting this synchronizationLockException in facebook canvas app. my issue is something similer to this. I have implemented facebook sdk also which is working properly but getting synchronizationLockException when trying to login into parse…
0
votes
1 answer

unlocking std::unique_lock without destroying it

If create a unique_lock as below, can I unlock it without destroying or getting out of scope? In other words is this safe/acceptable? std::mutex queueMutex; // My understanding is that this locks the mutex std::unique_lock
gmmo
  • 2,577
  • 3
  • 30
  • 56
0
votes
1 answer

Process synchronization - Critical section

I am studying for my final in OS. Currently on process sync chapter. Our book is offering the following algorithm to deal with Critical Section. It claims that the algorithm solves the problem of starvation and offers bounded wait. Here is the…
0
votes
1 answer

How to Block a thread on CPU then awaking it?

How to block a thread on CPU (So it doesn't use CPU time) and then awaking it after a time t without using signal mechanism.
0
votes
4 answers

Performance of synchronization

This is similar to my previous question as I am still unclear with synchronized keyword. This time I'll make it very short . private int count = 0; synchronized void increment() { count++; } count is an instance variable which is shared among…
Javed Solkar
  • 162
  • 11
0
votes
1 answer

Concurrent Hash Map get and put overlapping

I have read that get method is fully concurrent in ConcurrentHashMap(Jdk 7 ) and so it can overlap with all update operations. What will happen if two threads run put(Key,V) and Get (Key) concurrently if Key is not already present?
0
votes
1 answer

Atomic instruction : How can other thread update the value while Compare and Swap instruction is in progress?

As per my understanding, any atomic instructions(compare_and_swap, test_and_test, fetch_and_add) are executed as a single instruction. Though they involve multiple CPU cycles/operations, it is invisible to the thread/process. If a thread is…
0
votes
1 answer

How to stop my program with interleaved thread

Re-learning multithreading there :) I'm trying to use two threads to print them alternatively even and odd numbers until 50. public class Threading { private static final Object lock = new Object(); private static int i = 0; public…
user2336315
  • 15,697
  • 10
  • 46
  • 64
0
votes
0 answers

Why does this circular buffer design not require any synchronization?

In Wikipedia: CircularBuffer section "Difficulties->Always keep one slot open", the author does not mention any requirement of synchronization between threads: Always keep one slot open This design always keeps one slot unallocated. A full buffer…