Showing posts with label Threads. Show all posts
Showing posts with label Threads. Show all posts

Thursday, June 10, 2010

POSIX(R) Threads

Reading "Programming with POSIX(R) Threads".

Asynchronous:
Any two operations are “asynchronous” when they can proceed independently of each other.

Amazon wish list

“If seven maids with seven mops
Swept it for half a year,
Do you suppose,” the Walrus said,
“That they could get it clear?”
“I doubt it,” said the Carpenter,
And shed a bitter tear.

—Lewis Carroll, Through the Looking-Glass


  • pthread_t thread;
  • int pthread_equal (pthread_t t1, pthread_t t2);
  • int pthread_create ( pthread_t *thread, const pthread_attr_t *attr, void *( *start) (void *), void *arg);
  • pthread_t pthread_self (void);
  • int sched_yield ( void);
  • int pthread_exit ( void *value_ptr);
  • int pthread_detach ( pthread_t thread);
  • int pthread_join ( pthread_t thread, void **value_ptr);

Tuesday, June 23, 2009

The Thread Control Escape Rule

When trying to determine if your code's access of a certain resource is thread safe you can use the thread control escape rule:

If a resource is created, used and disposed within
the control of the same thread,
and never escapes the control of this thread,
the use of that resource is thread safe.

Resources can be any shared resource like an object, array, file, database connection, socket etc. In Java you do not always explicitly dispose objects, so "disposed" means losing or null'ing the reference to the object.

Taken from: http://tutorials.jenkov.com/java-concurrency/thread-safety.html