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
1 answer

Difference between threads states

In java a thread can be stopped in two ways either by user (by calling sleep or wait) or by a synchronized block. The thread stops working or is blocked (waiting for a lock to be released by some other thread) when it tries to enter the synchronized…
0
votes
3 answers

Console.writeline() multithreading problems

I am trying to mock up of a chat client. First here's the code using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace thread { class Program { public static Thread t1; …
Win Coder
  • 6,628
  • 11
  • 54
  • 81
0
votes
2 answers

scheduling a periodic task after other threads finish

I want to have 3 threads doing a task concurrently and also I want a thread that do a scheduled task over a period of time (runs every 10 secs). But I want when the 3 threads finish to run only once the scheduled task and then I want this thread to…
Manos
  • 151
  • 2
  • 12
0
votes
1 answer

Android Game development - Use of Threads for BOT players and AndEngine configuration

I'm writing my first ever Android game. It's a simple card game where player will have 3 BOT players. Right now i'm writing a core logic for it in pure java. (Not thinking much about AndEngine and graphics yet) The game has two phase: Initially…
0
votes
1 answer

terminating a thread immediately

I have implemented a parallel running thread.What i want is that whenever the user presses a button, say 'p', the thread should stop immediately. My code is: bool b=false; pthread_t thread1=0; void handlerforfunc3(void*…
AvinashK
  • 3,309
  • 8
  • 43
  • 94
0
votes
1 answer

Pthread Synchronization using mutex

I got a tough problem about Pthread I cannot figure it out. I use mutex to synchronize the subthread and main thread. But when I lock subFinished[i] in the main thread, it just cannot get it locked, and stuck there. It sometimes went well,…
Peiyun
  • 149
  • 1
  • 7
0
votes
2 answers

suspend execution of other function in a multithreaded application

I am implementing FIFO in C. One thread is writing in FIFO and other is reading from it. #define BUFFER_LENGTH 1000 struct Frame { char data[1024]; unsigned int data_len; struct Frame* frame; }; struct Frame * get_from_fifo () { …
Suresh Kumar
  • 1,077
  • 1
  • 12
  • 21
0
votes
1 answer

Multithread with TCPclient

I do have a problem with a multithreaded TCPClient application, every Client object has a Thread that recievies and sends messages and a thread that handle the Tasks that should be handled (depending on the messages)... (for example creates and…
Nick3
  • 639
  • 1
  • 14
  • 40
0
votes
1 answer

Eclipse RCP-- how to do Pause/Resume button functionality with threads using(wait and notify)

Problem statement:-- I have a UI button "Perform"-- which will initiate a big background process in loop in a different thread sequentially. As soon the process is started the button text will be toggled to "Pause" Now on press of "Pause", I need…
Nicks
  • 16,030
  • 8
  • 58
  • 65
0
votes
1 answer

C: thread_mutex Sync

I am having a problem with multiple thread synchronization, I will post only an example of what I am doing to "try" the synchronization because the original code is larger. Basically I have a heavy process with 3 threads attached, to lock/unlock the…
guille8
  • 45
  • 4
-1
votes
1 answer

How can I wake a thread in macOS in a way that is async-signal-safe?

I have a GRPC server application I'm developing on macOS. In this application, I need to handle SIGINT and SIGTERM in order to terminate gracefully. Normally, on Linux, I would use POSIX semaphores, as the functions involved to wait and notify using…
-1
votes
1 answer

Java synchronisation with infinispan

I need to display number of users currently logged in to an application.. I am using one cache to store the current number of user. And i am doing this operations, When the user logged to an application i am fetching the number of users from the…
-1
votes
2 answers

Is there a POSSIBILITY for context switching to occur on a multi-core processor or does it ONLY HAPPEN on single-core processors?

https://en.wikipedia.org/wiki/Context_switch In computing, a context switch is the process of storing the state of a process or thread, so that it can be restored and resume execution at a later point, and then restoring a different, previously…
-1
votes
1 answer

The possible causes of a SynchronizationLockException

I'm making an image processing pipeline (with one thread per processing step) but I have been struggling with a SynchronizationLockException for a while. I can't figure out why it is raised. Here is the code : int bufferWriterPointer; lock…
Hidden_Bad
  • 33
  • 5
-1
votes
1 answer

How to Initialize a Mutex Inside a Struct?

I'm kind of new to multithreading, and this is a small piece of a very large homework for my operating systems class. Currently, I have a C++ struct as follows: struct arguments { std::string string1; std::string string2; pthread_mutex_t…
Ken
  • 35
  • 4