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

Understanding thread synchronization using semaphores

I'm trying to understand semaphores. If I want to print out something like @//}}} repeatedly (with \n after each character), how could I do that with semaphores printing only 1 visible character at a time? I have an idea on how to print out one…
ChiCity
  • 1
  • 1
0
votes
1 answer

How can I release the lock permanently if a condition is true inside the locked code section?

I have the following code with me, where I need to produce some Wrapper Objects. And once I produce enough Objects, I need to release the lock, as if the statement lock(lockObject) was never present inside the code. lock (lockObject) { if…
teenup
  • 7,459
  • 13
  • 63
  • 122
0
votes
1 answer

Synchronize aspx Page Load event

I have a code only ASPX page wich does some calculations on database data. I have then configured my hosting to have a scheduled task which calls the page once a day at 6:00 o clock in the morning. However, because of the existence of an alias on…
Lorenzo
  • 29,081
  • 49
  • 125
  • 222
0
votes
1 answer

Is there a way to get a notification, when the main thread stops in C#

I'm writing an application that uses a separate thread for logging. I'd like to stop the separate thread when the main thread stops. However I'm unable to figure out when to stop the logger thread exactly as I don't know when the main thread stops.…
0
votes
1 answer

Synchronizing on function parameter for multithreaded memoization

My core question is: how can I implement synchronization in a method on the combination of the object instance and the method parameter? Here are the details of my situation. I'm using the following code to implement memoization, adapted from this…
acjay
  • 34,571
  • 6
  • 57
  • 100
0
votes
1 answer

unable to start 2nd Thread in java

As I am new to Java Threads, I was just experimenting with my code. From Kathy' Sierra SCJP book, I learnt about thread.join() method. Then I learnt 'bout Synchronization. Below is the code in which I used thread.join() method instead of making…
JPG
  • 1,247
  • 5
  • 31
  • 64
0
votes
1 answer

Prevent access to a method if another thread is calling a different method

Suppose I have two threads, T1 and T2. I would like to ensure that if T1 is calling method A1(), then T2 cannot call method B1(). Similarly, if T1 is calling method A2(), then T2 should not be able to call method B2(). How might I achieve…
ZohebSiddiqui
  • 209
  • 3
  • 4
  • 14
0
votes
1 answer

Stopping a Thread inside a web container

I have a thread that is started when my web application starts (contextInitialized). All this thread does is, read data from the socket. public void run() { while (!Thread.currentThread().isInterrupted() || !this.isInterrupted() ||…
vvra
  • 2,832
  • 5
  • 38
  • 82
0
votes
1 answer

Multiple read-write synchronization issues in opencl local and global memories

I have an opencl kernel that finds the maximum ASCII character in a string. The problem is I cannot synchronize the multiple read-writes to global and local memories. I am trying to update a local_maximum character in shared memory, and at the end…
mb1994
  • 241
  • 3
  • 13
0
votes
1 answer

Why does sem_timedwait() not waking up?

I work on an embedded system with eCos: I have 2 threads within the same process and 1 semaphore. Thread A initializes a semaphore to 0 so that the 1st attempt to take it will block. Thread A sends a command to Thread B, providing a…
n0p
  • 3,399
  • 2
  • 29
  • 50
0
votes
0 answers

sending non blocking websocket messages from a single threaded java server

I run a gaming website, on a tomcat 7 platform, where a single java server thread handles all the incoming messages, and sends outgoing messages to the clients. The clients are websocket connections. even though I increased the TCP sockets in the…
0
votes
3 answers

How to make thread wait untill method of another class completes

Here is my example code: package javaapplication35; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.logging.Level; import java.util.logging.Logger; import static…
geo
  • 517
  • 1
  • 9
  • 28
0
votes
1 answer

Is it possible for two threads to communicate on the same open serial port?

If I open a serial port in thread 1 and then close it, I can open it in thread 2 and use it. In that way, I can allow multiple threads to communicate with the same port, as long as each thread closes the port and the next thread opens it. But would…
Cerran
  • 2,087
  • 2
  • 21
  • 33
0
votes
1 answer

How can I allow thread 2 to communicate on the port I opened in thread 1?

I'm trying to communicate with the same port using two different threads in a CLI C++ program (running on Windows but not using the Windows API). The port is a USB port (that leads to a converter to RS-232 and then to another device). I can…
Cerran
  • 2,087
  • 2
  • 21
  • 33
0
votes
3 answers

What can you do to stop running out of stack space when multithreading?

I've implemented a working multithreaded merge sort in C++, but I've hit a wall. In my implementation, I recursively split an input vector into two parts, and then thread these two parts: void MergeSort(vector *in) { if(in->size() < 2) …