Found 189169 results in 42399 files, showing top 50 files (show more).
github.com/apache/xerces2-j:tests/thread/Test.java: [ trunk, ] java
18: package thread;
657: class thread extends Thread {
661:     thread (ThreadInfo param) {
104: class ThreadInfo
111:     ThreadInfo() {
140: class ThreadParser extends HandlerBase
171: ThreadParser()
84:     int         numThreads;
109:     int        fThreadNum;      // Identifying number for this thread.
126: ThreadInfo      gThreadInfo[];
66:     int     checkSum;        // The XML checksum.  Set up by the main thread for
98: //  struct threadInfo  Holds information specific to an individual thread.
99: //                     One of these is set up for each thread in the test.
106:     boolean    fHeartBeat;      // Set true by the thread each time it finishes
577:         System.err.print("usage: java thread.Test [-v] [-threads nnn] [-time nnn] [-quiet] [-verbose] xmlfile...\n" +
600: //                          thread, before all of the worker threads are started.
649: //               thread termination.  Threads are stuck running here
651: //               main thread of the process (which never calls this
670:         System.out.println("Thread " + thInfo.fThreadNum + ": starting");
692:             System.out.println("Thread " + thInfo.fThreadNum +
726: } // class thread
796:         thread t = new thread(gThreadInfo[threadNum]);
803:     //                 display "." if some thread hasn't since previous "+"
811:             Thread.sleep(1000);
839:     //  To Do:  Run the main thread at higher priority, so that the worker threads
40:  * This program is a straight port of xerces/c/tests/ThreadTest.cpp
56: //                      and can safely be referenced by the test threads without
67:                              //   each file before the worker threads are started.
75: //                     During the test, the threads will access this info without
100: //                     The main program monitors the threads by looking
132: //  class ThreadParser   Bundles together a SAX parser and the SAX handlers
137: //                       in different threads.
168: //  ThreadParser constructor.  Invoked by the threads of the test program
263: //  addToCheckSum - private function, used within ThreadParser in
275: //  addToCheckSum - private function, used within ThreadParser in
468: } // class ThreadParser
516:             else if (argv[argnum].equals("-threads"))
583:             "     -threads nnn   Number of threads.  Default is 2. \n" +
644: //  threadMain   The main function for each of the swarm of test threads.
659:     ThreadInfo thInfo;
667:     ThreadParser thParser = null;
682:             thParser = new ThreadParser();
701:             System.err.println("\nThread " + thInfo.fThreadNum +
747:     // While we are still single threaded, parse each of the documents
751:     ThreadParser mainParser = new ThreadParser();
783:     //  Fire off the requested number of parallel threads
789:     gThreadInfo = new ThreadInfo[gRunInfo.numThreads];
791:     int threadNum;
792:     for (threadNum=0; threadNum < gRunInfo.numThreads; threadNum++)
794:         gThreadInfo[threadNum] = new ThreadInfo();
795:         gThreadInfo[threadNum].fThreadNum = threadNum;
801:     //  Loop, watching the heartbeat of the worker threads.
802:     //    Each second, display "+" when all threads have completed a parse
819:             for (threadNum=0; threadNum < gRunInfo.numThreads; threadNum++)
821:                 if (gThreadInfo[threadNum].fHeartBeat == false)
830:                 for (threadNum=0; threadNum < gRunInfo.numThreads; threadNum++)
831:                     gThreadInfo[threadNum].fHeartBeat = false;
838:     //  Tally up the total number of parses completed by each of the threads.
843:     for (threadNum=0; threadNum < gRunInfo.numThreads; threadNum++)
845:         totalParsesCompleted += gThreadInfo[threadNum].fParses;
853:     //  The threads are still running; we just return
114:         fThreadNum = -1;
487:     gRunInfo.numThreads = 2;
522:                     gRunInfo.numThreads = Integer.parseInt(argv[argnum]);
527:                 if (gRunInfo.numThreads < 0)
786:     if (gRunInfo.numThreads == 0)
github.com/fuchsia-mirror/magenta-benchmarks:threads.cc: [ master, ] c++
9: class Thread : public benchmark::Fixture {};
11: BENCHMARK_F(Thread, Create)(benchmark::State& state) {
13:   constexpr char tname[] = "test thread";
15:     if (zx_thread_create(zx_process_self(), tname, sizeof(tname), 0, &out) != ZX_OK) {
16:       state.SkipWithError("Failed to create thread");
25: BENCHMARK_F(Thread, CreateAndJoin)(benchmark::State& state) {
26:   zx_handle_t thread;
27:   constexpr char tname[] = "test thread";
29:     if (zx_thread_create(zx_process_self(), tname, sizeof(tname), 0, &thread) != ZX_OK) {
30:       state.SkipWithError("Failed to create thread");
48:     uintptr_t entry = reinterpret_cast<uintptr_t>(&zx_thread_exit);
50:     if (zx_thread_start(thread, entry, stack, 0, 0) != ZX_OK) {
51:       state.SkipWithError("Failed to start thread");
56:     if (zx_object_wait_one(thread, ZX_THREAD_TERMINATED, ZX_TIME_INFINITE, &observed) != ZX_OK) {
57:       state.SkipWithError("Failed to wait for thread");
62:     zx_handle_close(thread);
github.com/fuchsia-mirror/magenta-rs:src/thread.rs: [ master, ] rust
13: pub struct Thread(Handle);
5: //! Type-safe bindings for Zircon thread.
9: /// An object representing a Zircon thread.
14: impl_handle_based!(Thread);
android.googlesource.com/platform/tools/gpu:cc/gapic/thread.h: [ master, ] c++
25: class Thread {
39: inline Thread::Thread(uint64_t id) : mId(id) {}
18: #define GAPIC_THREAD_H
17: #ifndef GAPIC_THREAD_H
24: // Thread represents a single thread of execution in the process.
27:     // current returns the Thread representing the current thread of execution.
28:     static Thread current();
30:     // id returns the process-unique identifier for the Thread.
34:     inline Thread(uint64_t id);
41: inline uint64_t Thread::id() const {
47: #endif // GAPIC_THREAD_H
android.googlesource.com/platform/external/mockito:src/main/java/org/mockito/internal/util/concurrent/DetachedThreadLocal.java: [ master, ] java
136:         THREAD, INLINE, MANUAL
14: public class DetachedThreadLocal<T> implements Runnable {
18:     public DetachedThreadLocal(Cleaner cleaner) {
9:  * A detached local that allows for explicit control of setting and removing values from a thread-local
12:  * Instances of this class are non-blocking and fully thread safe.
16:     final WeakConcurrentMap<Thread, T> map;
20:             case THREAD:
22:                 map = new WeakConcurrentMap<Thread, T>(cleaner == Cleaner.THREAD) {
24:                     protected T defaultValue(Thread key) {
30:                 map = new WeakConcurrentMap.WithInlinedExpunction<Thread, T>() {
32:                     protected T defaultValue(Thread key) {
43:         return map.get(Thread.currentThread());
47:         map.put(Thread.currentThread(), value);
51:         map.remove(Thread.currentThread());
55:      * Clears all thread local references for all threads.
62:      * @param thread The thread to which this thread's thread local value should be pushed.
65:     public T pushTo(Thread thread) {
68:             map.put(thread, inheritValue(value));
74:      * @param thread The thread from which the thread thread local value should be fetched.
77:     public T fetchFrom(Thread thread) {
78:         T value = map.get(thread);
86:      * @param thread The thread for which to set a thread-local value.
87:      * @return The value associated with this thread.
89:     public T get(Thread thread) {
90:         return map.get(thread);
94:      * @param thread The thread for which to set a thread-local value.
97:     public void define(Thread thread, T value) {
98:         map.put(thread, value);
102:      * @param thread The thread for which an initial value is created.
103:      * @return The initial value for any thread local. If no default is set, the default value is {@code null}.
105:     protected T initialValue(Thread thread) {
118:      * @return The weak map that backs this detached thread local.
120:     public WeakConcurrentMap<Thread, T> getBackingMap() {
130:      * Determines the cleaning format. A reference is removed either by an explicitly started cleaner thread
131:      * associated with this instance ({@link Cleaner#THREAD}), as a result of interacting with this thread local
132:      * from any thread ({@link Cleaner#INLINE} or manually by submitting the detached thread local to a thread
25:                         return DetachedThreadLocal.this.initialValue(key);
33:                         return DetachedThreadLocal.this.initialValue(key);
github.com/googlecreativelab/chrome-music-lab:harmonics & strings/js/Thread.js: [ master, ] javascript
5: var Thread = function(xp0Pm, yp0Pm, xp1Pm, yp1Pm, indPm, indHarmonicPm, isTopPm, threadControllerPm) {
1: // class:	Thread
52: 	// how close do we have to be to instantly grab a thread - perpendicular distance (px)
60: 	// total length of this thread (when unstretched)
131: Thread.prototype.init = function() {
140: Thread.prototype.redraw = function() {
185: Thread.prototype.upd = function() {
186: 	// is thread currently grabbed
189: 	// is thread currently oscillating
198: Thread.prototype.updOsc = function() {
248: Thread.prototype.updGrab = function() {
250: 	// is this thread being held by a fish?
291: Thread.prototype.stopNote = function() {
298: Thread.prototype.pluck = function(xp, yp, byUser, fish) {
366: Thread.prototype.grab = function(xp, yp, byUser, car) {
386: Thread.prototype.drop = function() {
416: Thread.prototype.startOsc = function() {
430: Thread.prototype.playNote = function(vol, pan) {
445: Thread.prototype.setStretch = function(r) {
452: // desc:      Check when user first clicks if they clicked right on top of a thread,
455: Thread.prototype.checkInstantGrab = function() {
479: // desc:      Check when user first clicks if they clicked right on top of a thread,
482: Thread.prototype.setPosition = function(x0, y0, x1, y1) {
6: 	this.m = threadControllerPm;
67: 	// my overall index number of all threads
278: 		this.m.dropThread(this);
474: 		this.m.grabThread(this, xu, yu, true, null);
android.googlesource.com/platform/external/regex-re2:re2/nfa.cc: [ master, ] c++
57:   struct Thread {
82:   typedef SparseArray<Thread*> Threadq;
157: void NFA::FreeThread(Thread *t) {
164: NFA::Thread* NFA::AllocThread() {
123:   Thread* free_threads_;  // free list
186: void NFA::AddToThreadq(Threadq* q, int id0, int flag,
60:       Thread* next;  // when on free list
84:   inline Thread* AllocThread();
85:   inline void FreeThread(Thread*);
149:   Thread* next;
150:   for (Thread* t = free_threads_; t; t = next) {
165:   Thread* t = free_threads_;
167:     t = new Thread;
220:     Thread** tp = &q->find(id)->second;
222:     Thread* t;
296:     Thread* t = i->second;
394: // Returns whether haystack contains needle's memory.
395: static bool StringPieceContains(const StringPiece haystack, const StringPiece needle) {
396:   return haystack.begin() <= needle.begin() &&
397:          haystack.end() >= needle.end();
504:         Thread* t = i->second;
561:     // Start a new thread if there have not been any matches.
562:     // (No point in starting a new thread if there have been
583:       // temporarily to hold match boundaries for new thread.
79:   // Threadq is a list of threads.  The list is sorted by the order
89:   void AddToThreadq(Threadq* q, int id, int flag,
98:   inline int Step(Threadq* runq, Threadq* nextq, int c, int flag, const char* p);
116:   Threadq q0_, q1_;     // pre-allocated for Search.
142:   free_threads_ = NULL;
160:   t->next = free_threads_;
161:   free_threads_ = t;
171:   free_threads_ = t->next;
234:       t = AllocThread();
266:       t = AllocThread();
290: // Frees all the threads on runq.
292: int NFA::Step(Threadq* runq, Threadq* nextq, int c, int flag, const char* p) {
295:   for (Threadq::iterator i = runq->begin(); i != runq->end(); ++i) {
301:       // Can skip any threads started after our current best match.
303:         FreeThread(t);
328:           FreeThread(t);
330:             FreeThread(i->second);
357:           // Cut off the threads that can only find matches
359:           // rest of the current Threadq.
361:           FreeThread(t);
363:             FreeThread(i->second);
372:     FreeThread(t);
460:   Threadq* runq = &q0_;
461:   Threadq* nextq = &q1_;
503:       for (Threadq::iterator i = runq->begin(); i != runq->end(); ++i) {
589:     // If all the threads have died, stop early.
605:   for (Threadq::iterator i = runq->begin(); i != runq->end(); ++i)
606:     FreeThread(i->second);
65:   // State for explicit stack in AddToThreadq.
119:   AddState* astack_;    // pre-allocated for AddToThreadq
226:       LOG(DFATAL) << "unhandled " << ip->opcode() << " in AddToThreadq";
319:           AddToThreadq(nextq, ip->out(), flag, p+1, t->capture);
585:       AddToThreadq(runq, start_, flag, p, match_);
github.com/html5rocks/www.html5rocks.com:content/tutorials/doodles/lem/static/code/lem-const.js: [ master, ] javascript
185:   'needle': ['intro-finale/items-needle-thread', 'intro-finale/items-needle'],
220:   'thread': ['intro-finale/items-thread', 'intro-finale/items-thread'],
218:   'thread-thimble': ['intro-finale/items-thread-thimble',
219:                      'intro-finale/items-thread-thimble'],
236:     'needle', 'halo', 'noodles', 'neutron', 'nose'
239:     'thread', 'pinstripe', 'neutron', 'noodles', 'clove'
259:     'thread', 'thimble', 'earmuffs', 'neutron', 'nose'
265:     'thread', 'thimble', 'noodles', 'neutron', 'nose', 'gnocchi', 'rivet',
github.com/apache/abdera:examples/src/main/java/org/apache/abdera/examples/ext/Thread.java: [ trunk, ] java
30: public class Thread {
21: import org.apache.abdera.ext.thread.InReplyTo;
22: import org.apache.abdera.ext.thread.ThreadHelper;
27:  * The Atom Threading Extensions are described in RFC4685 and provide a means of representing threaded discussions and
42:         ThreadHelper.addInReplyTo(e2, e1);
45:         InReplyTo irt = ThreadHelper.getInReplyTo(e2);
52:         ThreadHelper.setCount(replies, 10);
55:         ThreadHelper.addTotal(e1, 10);
github.com/google/skylark:eval.go: [ master, ] go
27: type Thread struct {
106: 	thread  *Thread         // thread-associated state
231: 	Thread *Thread
24: // A Thread contains the state of a Skylark thread,
25: // such as its call stack and thread-local storage.
26: // The Thread is threaded throughout the evaluator.
34: 	Print func(thread *Thread, msg string)
41: 	Load func(thread *Thread, module string) (StringDict, error)
43: 	// locals holds arbitrary "thread-local" values belonging to the client.
47: // SetLocal sets the thread-local value associated with the specified key.
49: func (thread *Thread) SetLocal(key string, value interface{}) {
50: 	if thread.locals == nil {
51: 		thread.locals = make(map[string]interface{})
53: 	thread.locals[key] = value
56: // Local returns the thread-local value associated with the specified key.
57: func (thread *Thread) Local(key string) interface{} {
58: 	return thread.locals[key]
63: func (thread *Thread) Caller() *Frame {
64: 	return thread.frame
159: 				return v.fn(fr.thread, v, nil, nil)
224: func ExecFile(thread *Thread, filename string, src interface{}, globals StringDict) error {
225: 	return Exec(ExecOptions{Thread: thread, Filename: filename, Source: src, Globals: globals})
230: 	// Thread is the state associated with the Skylark thread.
248: 	BeforeExec func(*Thread, syntax.Node) error
268: 	thread := opts.Thread
271: 		if err := opts.BeforeExec(thread, f); err != nil {
276: 	fr := thread.Push(globals, len(f.Locals))
278: 	thread.Pop()
286: // Push pushes a new Frame on the specified thread's stack, and returns it.
288: func (thread *Thread) Push(globals StringDict, nlocals int) *Frame {
290: 		thread:  thread,
291: 		parent:  thread.frame,
295: 	thread.frame = fr
299: // Pop removes the topmost frame from the thread's stack.
300: func (thread *Thread) Pop() {
301: 	thread.frame = thread.frame.parent
314: func Eval(thread *Thread, filename string, src interface{}, globals StringDict) (Value, error) {
325: 	fr := thread.Push(globals, len(locals))
327: 	thread.Pop()
524: 		if fr.thread.Load == nil {
528: 		dict, err := fr.thread.Load(fr.thread, module)
1152: 			needle, ok := x.(String)
1156: 			return Bool(strings.Contains(string(y), string(needle))), nil
1277: 	res, err := Call(fr.thread, fn, args, kwargs)
1369: func Call(thread *Thread, fn Value, args Tuple, kwargs []Tuple) (Value, error) {
1374: 	res, err := c.Call(thread, args, kwargs)
1675: func (fn *Function) Call(thread *Thread, args Tuple, kwargs []Tuple) (Value, error) {
1681: 	for fr := thread.frame; fr != nil; fr = fr.parent {
1690: 	fr := thread.Push(fn.globals, len(fn.syntax.Locals))
1696: 	thread.Pop()
android.googlesource.com/platform/external/avahi:avahi-common/thread-watch.c: [ master, ] c
62: static void* thread(void *userdata){
42:     pthread_t thread_id;
44:     int thread_running;
77: AvahiThreadedPoll *avahi_threaded_poll_new(void) {
107: void avahi_threaded_poll_free(AvahiThreadedPoll *p) {
123: const AvahiPoll* avahi_threaded_poll_get(AvahiThreadedPoll *p) {
129: int avahi_threaded_poll_start(AvahiThreadedPoll *p) {
142: int avahi_threaded_poll_stop(AvahiThreadedPoll *p) {
161: void avahi_threaded_poll_quit(AvahiThreadedPoll *p) {
170: void avahi_threaded_poll_lock(AvahiThreadedPoll *p) {
179: void avahi_threaded_poll_unlock(AvahiThreadedPoll *p) {
40: struct AvahiThreadedPoll {
38: #include "thread-watch.h"
53:      * avahi_simple_poll_quit() can succeed from another thread. */
66:     /* Make sure that signals are delivered to the main thread */
90:     p->thread_running = 0;
110:     /* Make sure that this function is not called from the helper thread */
111:     assert(!p->thread_running || !pthread_equal(pthread_self(), p->thread_id));
113:     if (p->thread_running)
132:     assert(!p->thread_running);
134:     if (pthread_create(&p->thread_id, NULL, thread, p) < 0)
137:     p->thread_running = 1;
145:     if (!p->thread_running)
148:     /* Make sure that this function is not called from the helper thread */
149:     assert(!pthread_equal(pthread_self(), p->thread_id));
155:     pthread_join(p->thread_id, NULL);
156:     p->thread_running = 0;
164:     /* Make sure that this function is called from the helper thread */
165:     assert(pthread_equal(pthread_self(), p->thread_id));
173:     /* Make sure that this function is not called from the helper thread */
174:     assert(!p->thread_running || !pthread_equal(pthread_self(), p->thread_id));
182:     /* Make sure that this function is not called from the helper thread */
183:     assert(!p->thread_running || !pthread_equal(pthread_self(), p->thread_id));
31: #include <pthread.h>
43:     pthread_mutex_t mutex;
49:     pthread_mutex_t *mutex = userdata;
55:     pthread_mutex_unlock(mutex);
57:     pthread_mutex_lock(mutex);
68:     pthread_sigmask(SIG_BLOCK, &mask, NULL);
70:     pthread_mutex_lock(&p->mutex);
72:     pthread_mutex_unlock(&p->mutex);
86:     pthread_mutex_init(&p->mutex, NULL);
98:             pthread_mutex_destroy(&p->mutex);
114:         avahi_threaded_poll_stop(p);
119:     pthread_mutex_destroy(&p->mutex);
151:     pthread_mutex_lock(&p->mutex);
153:     pthread_mutex_unlock(&p->mutex);
176:     pthread_mutex_lock(&p->mutex);
185:     pthread_mutex_unlock(&p->mutex);
63:     AvahiThreadedPoll *p = userdata;
78:     AvahiThreadedPoll *p;
80:     if (!(p = avahi_new(AvahiThreadedPoll, 1)))
github.com/apache/commons-io:src/main/java/org/apache/commons/io/ThreadMonitor.java: [ master, ] java
42:     private final Thread thread;
40: class ThreadMonitor implements Runnable {
94:     private ThreadMonitor(final Thread thread, final long timeout) {
20:  * Monitors a thread, interrupting it if it reaches the specified timeout.
23:  * interrupting the thread being monitored. If the thread being monitored
25:  * the <i>monitor</i> thread.
31:  *           Thread monitor = ThreadMonitor.start(timeoutInMillis);
46:      * Start monitoring the current thread.
50:      * @return The monitor thread or {@code null}
53:     public static Thread start(final long timeout) {
54:         return start(Thread.currentThread(), timeout);
58:      * Start monitoring the specified thread.
60:      * @param thread The thread The thread to monitor
63:      * @return The monitor thread or {@code null}
66:     public static Thread start(final Thread thread, final long timeout) {
67:         Thread monitor = null;
69:             final ThreadMonitor timout = new ThreadMonitor(thread, timeout);
70:             monitor = new Thread(timout, ThreadMonitor.class.getSimpleName());
78:      * Stop monitoring the specified thread.
80:      * @param thread The monitor thread, may be {@code null}
82:     public static void stop(final Thread thread) {
83:         if (thread != null) {
84:             thread.interrupt();
91:      * @param thread The thread to monitor
95:         this.thread = thread;
101:      * interrupt the thread being monitored.
109:             thread.interrupt();
118:      * This method exists because Thread.sleep(100) can sleep for 0, 70, 100 or 200ms or anything else
119:      * it deems appropriate. Read the docs on Thread.sleep for further interesting details.
128:             Thread.sleep(remaining);
33:  *           ThreadMonitor.stop(monitor);
github.com/fuchsia-mirror/third_party-re2:re2/nfa.cc: [ master, ] c++
64:   struct Thread {
88:   typedef SparseArray<Thread*> Threadq;
165: NFA::Thread* NFA::AllocThread() {
129:   Thread* free_threads_;  // free list
206: void NFA::AddToThreadq(Threadq* q, int id0, int c, int flag,
67:       Thread* next;  // when on free list
75:     Thread* t;  // if not null, set t0 = t before processing id
81:     AddState(int id, Thread* t)
90:   inline Thread* AllocThread();
91:   inline Thread* Incref(Thread* t);
92:   inline void Decref(Thread* t);
97:   // p is the current input position, and t0 is the current thread.
99:                     const char* p, Thread* t0);
157:   Thread* next;
158:   for (Thread* t = free_threads_; t; t = next) {
166:   Thread* t = free_threads_;
168:     t = new Thread;
178: NFA::Thread* NFA::Incref(Thread* t) {
184: void NFA::Decref(Thread* t) {
205: // p is the current input position, and t0 is the current thread.
207:                        const char* p, Thread* t0) {
228:       // t0 was a thread that we allocated and copied in order to
248:     Thread** tp = &q->find(id)->second;
250:     Thread* t;
338:     Thread* t = i->second;
435: // Returns whether haystack contains needle's memory.
436: static bool StringPieceContains(const StringPiece haystack, const StringPiece needle) {
437:   return haystack.begin() <= needle.begin() &&
438:          haystack.end() >= needle.end();
548:         Thread* t = i->second;
599:     // Start a new thread if there have not been any matches.
600:     // (No point in starting a new thread if there have been
620:       Thread* t = AllocThread();
85:   // Threadq is a list of threads.  The list is sorted by the order
98:   void AddToThreadq(Threadq* q, int id0, int c, int flag,
107:   // Frees all the threads on runq.
109:   inline int Step(Threadq* runq, Threadq* nextq, int c, int flag, const char* p);
123:   Threadq q0_, q1_;     // pre-allocated for Search.
151:   free_threads_ = NULL;
173:   free_threads_ = t->next;
191:   t->next = free_threads_;
192:   free_threads_ = t;
287:         t = AllocThread();
332: // Frees all the threads on runq.
334: int NFA::Step(Threadq* runq, Threadq* nextq, int c, int flag, const char* p) {
337:   for (Threadq::iterator i = runq->begin(); i != runq->end(); ++i) {
343:       // Can skip any threads started after our current best match.
402:           // Cut off the threads that can only find matches
404:           // rest of the current Threadq.
500:   Threadq* runq = &q0_;
501:   Threadq* nextq = &q1_;
547:       for (Threadq::iterator i = runq->begin(); i != runq->end(); ++i) {
627:     // If all the threads have died, stop early.
637:   for (Threadq::iterator i = runq->begin(); i != runq->end(); ++i)
72:   // State for explicit stack in AddToThreadq.
126:   AddState* astack_;    // pre-allocated for AddToThreadq
144:   // See NFA::AddToThreadq() for why this is so.
254:       LOG(DFATAL) << "unhandled " << ip->opcode() << " in AddToThreadq";
360:         AddToThreadq(nextq, ip->out(), c, flag, p+1, t);
558:     // c and flag through to AddToThreadq() along with p-1+1, which is p.
623:       AddToThreadq(runq, start_, p < text.end() ? p[0] & 0xFF : -1, flag, p, t);
android.googlesource.com/platform/system/nfc:src/adaptation/NfcAdaptation.cc: [ master, ] c++
364: uint32_t NfcAdaptation::Thread(__attribute__((unused)) uint32_t arg) {
718: ThreadMutex::ThreadMutex() {
768: ThreadCondVar::ThreadCondVar() {
735: ThreadMutex::~ThreadMutex() { pthread_mutex_destroy(&mMutex); }
786: ThreadCondVar::~ThreadCondVar() { pthread_cond_destroy(&mCondVar); }
825: AutoThreadMutex::AutoThreadMutex(ThreadMutex& m) : mm(m) { mm.lock(); }
836: AutoThreadMutex::~AutoThreadMutex() { mm.unlock(); }
190:   // Android already logs thread_id, proc_id, timestamp, so disable those.
273:     GKI_create_task((TASKPTR)Thread, MMI_TASK, (int8_t*)"NFCA_THREAD", 0, 0,
331: ** Description: signal the CondVar to release the thread that is waiting
357: ** Function:    NfcAdaptation::Thread()
365:   const char* func = "NfcAdaptation::Thread";
54: ThreadMutex NfcAdaptation::sLock;
57: ThreadCondVar NfcAdaptation::mHalOpenCompletedEvent;
58: ThreadCondVar NfcAdaptation::mHalCloseCompletedEvent;
206:     // of a byte array is ambiguous and needlessly difficult to configure.
270:                   (pthread_cond_t*)NULL, NULL);
274:                     (pthread_cond_t*)NULL, NULL);
359: ** Description: Creates work threads
369:     ThreadCondVar CondVar;
372:                     (pthread_cond_t*)CondVar, (pthread_mutex_t*)CondVar);
711: ** Function:    ThreadMutex::ThreadMutex()
719:   pthread_mutexattr_t mutexAttr;
721:   pthread_mutexattr_init(&mutexAttr);
722:   pthread_mutex_init(&mMutex, &mutexAttr);
723:   pthread_mutexattr_destroy(&mutexAttr);
728: ** Function:    ThreadMutex::~ThreadMutex()
739: ** Function:    ThreadMutex::lock()
746: void ThreadMutex::lock() { pthread_mutex_lock(&mMutex); }
750: ** Function:    ThreadMutex::unblock()
757: void ThreadMutex::unlock() { pthread_mutex_unlock(&mMutex); }
761: ** Function:    ThreadCondVar::ThreadCondVar()
769:   pthread_condattr_t CondAttr;
771:   pthread_condattr_init(&CondAttr);
772:   pthread_cond_init(&mCondVar, &CondAttr);
774:   pthread_condattr_destroy(&CondAttr);
779: ** Function:    ThreadCondVar::~ThreadCondVar()
790: ** Function:    ThreadCondVar::wait()
797: void ThreadCondVar::wait() {
798:   pthread_cond_wait(&mCondVar, *this);
799:   pthread_mutex_unlock(*this);
804: ** Function:    ThreadCondVar::signal()
811: void ThreadCondVar::signal() {
813:   pthread_cond_signal(&mCondVar);
166:   AutoThreadMutex a(sLock);
272:     AutoThreadMutex guard(mCondVar);
293:   AutoThreadMutex a(sLock);
370:     AutoThreadMutex guard(CondVar);
812:   AutoThreadMutex a(*this);
818: ** Function:    AutoThreadMutex::AutoThreadMutex()
829: ** Function:    AutoThreadMutex::~AutoThreadMutex()
github.com/google/j2objc:jre_emul/Classes/java/lang/Thread.java: [ master, ] java
54: public class Thread implements Runnable {
187:   private static final String THREAD = "Thread-";
207:   public Thread() {
221:   public Thread(Runnable runnable) {
236:   public Thread(Runnable runnable, String threadName) {
249:   public Thread(String threadName) {
269:   public Thread(ThreadGroup group, Runnable runnable) {
291:   public Thread(ThreadGroup group, Runnable runnable, String threadName, long stack) {
312:   public Thread(ThreadGroup group, Runnable runnable, String threadName) {
330:   public Thread(ThreadGroup group, String threadName) {
334:   private Thread(
58:   private final Object nativeThread;
60:   private final long threadId;
68:   ThreadLocal.ThreadLocalMap threadLocals = null;
88:   private ThreadGroup threadGroup;
102:   private static long threadOrdinalNum = 1;
153:   long threadLocalRandomSeed;
154:   int threadLocalRandomProbe;
155:   int threadLocalRandomSecondarySeed;
196:   private static native Object newNativeThread() /*-[
379:   private static Thread createMainThread(Object nativeThread) {
394:   private static Thread createCurrentThread(Object nativeThread) {
398:   public static native Thread currentThread() /*-[
69:   ThreadLocal.ThreadLocalMap inheritableThreadLocals = null;
386:   private static native void initializeThreadClass() /*-[
553:   public ThreadGroup getThreadGroup() {
831:   private static synchronized long getNextThreadId() {
30: #import "java_lang_Thread.h"
46:  * Simplified iOS version of java.lang.Thread, based on Apache Harmony source
47:  * (both luni-kernel and vmcore). This class uses pthread for thread creation
49:  * pthread's thread local mechanism (pthread_setspecific) is used to associate
50:  * this wrapper object with the current thread.
80:   /** The object the thread is waiting on (normally null). */
83:   /** The object in which this thread is blocked in an interruptible I/O operation, if any. */
90:   /** the park state of the thread */
93:   /** The synchronization object responsible for this thread parking. */
100:    * Counter used to generate thread's ID
105:    * A representation of a thread's state. A given thread may only be in one
110:      * The thread has been created, but has never been started.
114:      * The thread may be run.
118:      * The thread is blocked and waiting for a lock.
122:      * The thread is waiting.
126:      * The thread is waiting for a specified amount of time.
130:      * The thread has been terminated.
149:     void uncaughtException(Thread t, Throwable e);
165:    * The maximum priority value allowed for a thread.
172:    * The minimum priority value allowed for a thread.
185:    * used to generate a default thread name
189:   // Milliseconds between polls for testing thread completion.
201:    * Constructs a new Thread with no runnable object and a newly generated
202:    * name. The new Thread will belong to the same ThreadGroup as the Thread
208:     this(null, null, THREAD, 0, null);
212:    * Constructs a new Thread with a runnable object and a newly generated
213:    * name. The new Thread will belong to the same ThreadGroup as the Thread
217:    *        be executed by the new Thread
222:     this(null, runnable, THREAD, 0, null);
226:    * Constructs a new Thread with a runnable object and name provided. The new
227:    * Thread will belong to the same ThreadGroup as the Thread calling this
231:    *        be executed by the new Thread
232:    * @param threadName Name for the Thread being created
241:    * Constructs a new Thread with no runnable object and the name provided.
242:    * The new Thread will belong to the same ThreadGroup as the Thread calling
245:    * @param threadName Name for the Thread being created
254:    * Constructs a new Thread with a runnable object and a newly generated
255:    * name. The new Thread will belong to the ThreadGroup passed as parameter.
257:    * @param group ThreadGroup to which the new Thread will belong
259:    *        be executed by the new Thread
270:     this(group, runnable, THREAD, 0, null);
274:    * Constructs a new Thread with a runnable object, the given name and
277:    * @param group ThreadGroup to which the new Thread will belong
279:    *        be executed by the new Thread
280:    * @param threadName Name for the Thread being created
296:    * Constructs a new Thread with a runnable object, the given name and
299:    * @param group ThreadGroup to which the new Thread will belong
301:    *        be executed by the new Thread
302:    * @param threadName Name for the Thread being created
317:    * Constructs a new Thread with no runnable object, the given name and
320:    * @param group ThreadGroup to which the new Thread will belong
321:    * @param threadName Name for the Thread being created
338:     if (name.equals(THREAD)) {
344:       // Thread is not yet started.
345:       Thread currentThread = currentThread();
352:       // Thread is already running.
362:     JavaLangThread *thread = (JavaLangThread *)arg;
363:     pthread_setspecific(java_thread_key, thread);
366:         [thread run];
368:         JavaLangThread_rethrowWithJavaLangThrowable_(thread, t);
371:             thread, create_JavaLangThrowable_initWithNSString_(
380:     return new Thread(ThreadGroup.mainThreadGroup, null, "main", 0, nativeThread);
384:    * Create a Thread wrapper around the main native thread.
391:     pthread_setspecific(java_thread_key, [mainThread retain]);
395:     return new Thread(ThreadGroup.mainThreadGroup, null, THREAD, 0, nativeThread);
399:     JavaLangThread *thread = pthread_getspecific(java_thread_key);
400:     if (thread) {
401:       return thread;
405:     thread = JavaLangThread_createCurrentThreadWithId_(nt);
406:     pthread_setspecific(java_thread_key, [thread retain]);
407:     return thread;
412:       throw new IllegalThreadStateException("This thread was already started!");
474:    * stack for this Thread.
482:   public static int enumerate(Thread[] threads) {
483:     Thread thread = Thread.currentThread();
484:     return thread.getThreadGroup().enumerate(threads);
600:    * Posts an interrupt request to this {@code Thread}. Unless the caller is
604:    * the state of this {@code Thread}:
607:    * {@code Thread}s blocked in one of {@code Object}'s {@code wait()} methods
608:    * or one of {@code Thread}'s {@code join()} or {@code sleep()} methods will
612:    * {@code Thread}s blocked in an I/O operation of an
618:    * {@code Thread}s blocked in a {@link java.nio.channels.Selector} will have
627:    * @see Thread#interrupted
628:    * @see Thread#isInterrupted
658:    * Returns a <code>boolean</code> indicating whether the current Thread (
664:    * @see Thread#currentThread
665:    * @see Thread#interrupt
666:    * @see Thread#isInterrupted
669:     Thread currentThread = currentThread();
681:    * @see Thread#interrupt
682:    * @see Thread#interrupted
689:    * Blocks the current Thread (<code>Thread.currentThread()</code>) until
710:    * Blocks the current Thread (<code>Thread.currentThread()</code>) until
725:    * Blocks the current Thread (<code>Thread.currentThread()</code>) until
761:           // wait until this thread completes or the timeout has elapsed
811:           if (Thread.interrupted()) {
824:    * Causes the calling Thread to yield execution time to another Thread that
836:    * Indicates whether the current Thread has a monitor lock on the specified
840:    * @return true if the current thread has a monitor lock on the specified
848:    * Returns the context ClassLoader for this Thread.
864:       return "Thread[" + getName() + "," + getPriority() + "," + group.getName() + "]";
866:     return "Thread[" + getName() + "," + getPriority() + ",]";
870:    * Unparks this thread. This unblocks the thread it if it was
871:    * previously parked, or indicates that the thread is "preemptively
873:    * next time the thread is told to park, it will merely clear its
889:            * preemptively unparked thread is to remain in
909:    * Parks the current thread for a particular number of nanoseconds, or
910:    * indefinitely. If not indefinitely, this method unparks the thread
911:    * after the given number of nanoseconds if no other thread unparks it
912:    * first. If the thread has been "preemptively unparked," this method
914:    * also return spuriously (that is, without the thread being told to
921:    * thread.
967:    * Parks the current thread until the specified system time. This
968:    * method attempts to unpark the current thread immediately after
970:    * value, if no other thread unparks it first. If the thread has
973:    * spuriously (that is, without the thread being told to unpark
980:    * current thread.
982:    * @param time the time after which the thread should be unparked,
1017:    * exception terminates a thread.
1028:    * case any Thread dies due to an unhandled exception.
1034:       Thread.defaultUncaughtHandler = handler;
1038:    * Returns the handler invoked when this thread abruptly terminates
1039:    * due to an uncaught exception. If this thread has not had an
1040:    * uncaught exception handler explicitly set then this thread's
1041:    * <tt>ThreadGroup</tt> object is returned, unless this thread
1051:    * Set the handler invoked when this thread abruptly terminates
1053:    * <p>A thread can take full control of how it responds to uncaught
1055:    * If no such handler is set then the thread's <tt>ThreadGroup</tt>
1057:    * @param eh the object to use as this thread's uncaught exception
1058:    * handler. If <tt>null</tt> then this thread has no explicit handler.
1059:    * @throws  SecurityException  if the current thread is not allowed to
1060:    *          modify this thread.
1072:     public synchronized void uncaughtException(Thread t, Throwable e) {
1073:       System.err.print("Exception in thread \"" + t.getName() + "\" ");
1079:    * Adds a runnable to be invoked upon interruption. If this thread has
1121:   public static Map<Thread,StackTraceElement[]> getAllStackTraces() {
1122:     return Collections.<Thread, StackTraceElement[]>emptyMap();
32: #import <pthread.h>
36: @interface NativeThread : NSObject {
38:   pthread_t t;
41: @implementation NativeThread
48:  * and maintains a pthread handle for using other pthread functionality.
57:   /** Android source declares this as the native VMThread class. */
152:   // Fields accessed reflectively by ThreadLocalRandom.
179:    * The normal (default) priority value assigned to threads.
197:     return [[[NativeThread alloc] init] autorelease];
205:    * @see java.lang.ThreadGroup
218:    * @see java.lang.ThreadGroup
233:    * @see java.lang.ThreadGroup
237:     this(null, runnable, threadName, 0, null);
246:    * @see java.lang.ThreadGroup
250:     this(null, null, threadName, 0, null);
264:    * @see java.lang.ThreadGroup
275:    * belonging to the ThreadGroup passed as parameter.
286:    * @see java.lang.ThreadGroup
292:     this(group, runnable, threadName, stack, null);
297:    * belonging to the ThreadGroup passed as parameter.
307:    * @see java.lang.ThreadGroup
313:     this(group, runnable, threadName, 0, null);
318:    * belonging to the ThreadGroup passed as parameter.
326:    * @see java.lang.ThreadGroup
331:     this(group, null, threadName, 0, null);
335:       ThreadGroup group, Runnable runnable, String name, long stack, Object nativeThread) {
337:     this.threadId = getNextThreadId();
339:       name += threadId;
343:     if (nativeThread == null) {
346:       nativeThread = newNativeThread();
347:       this.priority = currentThread.getPriority();
349:         group = currentThread.getThreadGroup();
356:     this.threadGroup = group;
357:     this.nativeThread = nativeThread;
370:         JavaLangThread_rethrowWithJavaLangThrowable_(
388:     NativeThread *nt = [[[NativeThread alloc] init] autorelease];
389:     nt->t = pthread_self();
390:     JavaLangThread *mainThread = JavaLangThread_createMainThreadWithId_(nt);
403:     NativeThread *nt = [[[NativeThread alloc] init] autorelease];
404:     nt->t = pthread_self();
414:     threadGroup.add(this);
423:     NativeThread *nt = (NativeThread *)self->nativeThread_;
424:     pthread_attr_t attr;
425:     pthread_attr_init(&attr);
427:     if (stack >= PTHREAD_STACK_MIN) {
428:       pthread_attr_setstacksize(&attr, stack);
430:     pthread_create(&nt->t, &attr, &start_routine, [self retain]);
435:     if (threadGroup != null) {
436:       threadGroup.threadTerminated(this);
437:       threadGroup = null;
461:       return currentThread().getThreadGroup().activeCount();
488:     return threadId;
508:     ThreadGroup g;
528:     param.sched_priority = (priority * 64 / JavaLangThread_MAX_PRIORITY) - 1;
529:     NativeThread *nt = (NativeThread *)self->nativeThread_;
530:     pthread_setschedparam(nt->t, SCHED_OTHER, &param);
554:     return state == STATE_TERMINATED ? null : threadGroup;
601:    * the {@link #currentThread()}, the method {@code checkAccess()} is called
631:     synchronized(nativeThread) {
659:    * <code>currentThread()</code>) has a pending interrupt request (<code>
670:     boolean result = currentThread.interrupted;
671:     currentThread.interrupted = false;
695:    * @see java.lang.ThreadDeath
702:       synchronized (nativeThread) {
704:               nativeThread.wait(POLL_INTERVAL);
718:    * @see java.lang.ThreadDeath
734:    * @see java.lang.ThreadDeath
753:       synchronized (nativeThread) {
765:                 nativeThread.wait(POLL_INTERVAL);
767:                 nativeThread.wait(millis, nanos);
817:       Object lock = currentThread().nativeThread;
828:     pthread_yield_np();
832:     return threadOrdinalNum++;
862:     ThreadGroup group = getThreadGroup();
882:     Object vmt = nativeThread;
930:     Object vmt = nativeThread;
988:     Object vmt = nativeThread;
1047:     return h != null ? h : threadGroup;
1062:    * @see ThreadGroup#uncaughtException
1118:    * Returns a map of stack traces for all live threads.
1127:     stop(new ThreadDeath());
193:     initializeThreadClass();
262:    * @throws IllegalThreadStateException if <code>group.destroy()</code> has
284:    * @throws IllegalThreadStateException if <code>group.destroy()</code> has
305:    * @throws IllegalThreadStateException if <code>group.destroy()</code> has
324:    * @throws IllegalThreadStateException if <code>group.destroy()</code> has
387:     initJavaThreadKeyOnce();
513:     if ((g = getThreadGroup()) != null) {
android.googlesource.com/platform/external/nist-sip:java/gov/nist/core/ThreadAuditor.java: [ master, ] java
36:         private Thread thread;
23: public class ThreadAuditor {
25:     private Map<Thread,ThreadHandle> threadHandles = new HashMap<Thread,ThreadHandle>();
31:     public class ThreadHandle {
39:         private ThreadAuditor threadAuditor;
42:         public ThreadHandle(ThreadAuditor aThreadAuditor) {
59:         public Thread getThread() {
102:     public synchronized ThreadHandle addCurrentThread() {
113:     public synchronized void removeThread(Thread thread) {
33:         private boolean isThreadActive;
49:         public boolean isThreadActive() {
54:         protected void setThreadActive(boolean value) {
132:     public synchronized String auditThreads() {
6:  * Thread Auditor class:
15:  *     the thread can periodically ping the auditor.
32:         /// Set to true when the thread pings, periodically reset to false by the auditor
35:         /// Thread being monitored
38:         /// Thread auditor monitoring this thread
44:             thread = Thread.currentThread();
48:         /// Called by the auditor thread to check the ping status of the thread
53:         /// Called by the auditor thread to reset the ping status of the thread
58:         /// Return the thread being monitored
60:             return thread;
80:                     .append("Thread Name: ").append(thread.getName())
81:                     .append(", Alive: ").append(thread.isAlive());
86:     /// Indicates how often monitored threads are supposed to ping (0 = no thread monitoring)
101:     /// Called by a thread that wants to be monitored
103:         // Create and return a thread handle but only add it
107:             threadHandles.put(Thread.currentThread(), threadHandle);
112:     /// Stops monitoring a given thread
114:         threadHandles.remove(thread);
117:     /// Called by a monitored thread reporting that it's alive and well
141:                 // Get the non-responsive thread
142:                 Thread thread = threadHandle.getThread();
146:                     auditReport = "Thread Auditor Report:\n";
148:                 auditReport += "   Thread [" + thread.getName() + "] has failed to respond to an audit request.\n";
156:                 //      stackTraces = Thread.getAllStackTraces();
159:                 //  // Get the stack trace for the non-responsive thread
160:                 //  StackTraceElement[] stackTraceElements = (StackTraceElement[])stackTraces.get(thread);
173:             // Reset the ping status of the thread
185:         String toString = "Thread Auditor - List of monitored threads:\n";
7:  *   - Provides a mechanism for applications to check the health of internal threads
9:  *   - Threads register with the auditor at startup and "ping" the auditor every so often.
11:  *     auditor reports if the threads are healthy or if any of them failed to ping and are
13:  *   - The main implication for the monitored threads is that they can no longer block
24:     /// Threads being monitored
27:     /// How often are threads supposed to ping
30:     /// Internal class, used as a handle by the monitored threads
45:             threadAuditor = aThreadAuditor;
63:         // Helper function to allow threads to ping using this handle
65:             threadAuditor.ping(this);
68:         // Helper function to allow threads to get the ping interval directly from this handle
70:             return threadAuditor.getPingIntervalInMillisecs();
91:     /// Defines how often monitored threads are supposed to ping
96:     /// Indicates if the auditing of threads is enabled
104:         // to the list of monitored threads if the auditor is enabled
105:         ThreadHandle threadHandle = new ThreadHandle(this);
109:         return threadHandle;
118:     public synchronized void ping(ThreadHandle threadHandle) {
119:         threadHandle.setThreadActive(true);
124:         threadHandles.clear();
128:      * Audits the sanity of all threads
136:         // Scan all monitored threads looking for non-responsive ones
137:         Iterator<ThreadHandle> it = threadHandles.values().iterator();
139:             ThreadHandle threadHandle = (ThreadHandle) it.next();
140:             if (!threadHandle.isThreadActive()) {
154:                 //  // Get stack traces for all live threads (do this only once per audit)
174:             threadHandle.setThreadActive(false);
186:         Iterator<ThreadHandle> it = threadHandles.values().iterator();
188:             ThreadHandle threadHandle = (ThreadHandle)it.next();
189:             toString += "   " + threadHandle.toString() + "\n";
43:             isThreadActive = false;
50:             return isThreadActive;
55:             isThreadActive = value;
github.com/apache/incubator-sdap-nexus:analysis/webservice/algorithms/doms/workerthread.py: [ master, ] python
57:     thread = WorkerThread(foo, params=("a", "b"))
19: class WorkerThread(threading.Thread):
22:         threading.Thread.__init__(self)
34:     for thread in threads:
35:         if not thread.completed:
43:         for thread in threads:
44:             thread.start()
58:     thread.start()
59:     while not thread.completed:
61:     print thread.results
16: import threading
33: def __areAllComplete(threads):
41: def wait(threads, startFirst=False, poll=0.5):
46:     while not __areAllComplete(threads):
47:         threading._sleep(poll)
60:         threading._sleep(0.5)
github.com/google/skia:dm/DM.cpp: [ master, ] c++
152:     SkThreadID thread;
1075: static SkTaskGroup gDefinitelyThreadSafeWork;
208:         if (task.thread == thisThread) {
1050: static bool match(const char* needle, const char* haystack) {
1051:     if ('~' == needle[0]) {
1052:         return !match(needle + 1, haystack);
1054:     if (0 == strcmp("_", needle)) {
1057:     return nullptr != strstr(haystack, needle);
1074: // .png encoding are definitely thread safe.  This lets us offload that work to CPU threads.
1419:     // With the parallel work running, run serial tasks and tests here on main thread.
74: DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?");
206:     SkThreadID thisThread = SkGetThreadID();
890:                                                 FLAGS_gpu_threading, grCtxOptions);
895:                                    FLAGS_gpu_threading, grCtxOptions);
1073: // Even when a Task Sink reports to be non-threadsafe (e.g. GPU), we know things like
1116:             // We're likely switching threads here, so we must capture by value, [=] or [foo,bar].
1270:             (FLAGS_gpu_threading ? gParallelTests : gSerialTests).push(test);
1365:     SkTaskGroup::Enabler enabled(FLAGS_threads);
1432:     // At this point we're back in single-threaded land.
201:     gRunning.push_back({id,SkGetThreadID()});
884:             if (gpuConfig->getTestThreading()) {
885:                 return new GPUThreadTestingSink(contextType, contextOverrides,
1118:             gDefinitelyThreadSafeWork.add([task,name,bitmap,data]{
1425:     gDefinitelyThreadSafeWork.wait();
android.googlesource.com/platform/external/skia:dm/DM.cpp: [ master, ] c++
136:     SkThreadID thread;
1031: static SkTaskGroup gDefinitelyThreadSafeWork;
192:         if (task.thread == thisThread) {
1012: static bool match(const char* needle, const char* haystack) {
1013:     return 0 == strcmp("_", needle) || nullptr != strstr(haystack, needle);
1030: // .png encoding are definitely thread safe.  This lets us offload that work to CPU threads.
1352:     // With the parallel work running, run serial tasks and tests here on main thread.
69: DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?");
190:     SkThreadID thisThread = SkGetThreadID();
858:                                FLAGS_gpu_threading);
1029: // Even when a Task Sink reports to be non-threadsafe (e.g. GPU), we know things like
1072:             // We're likely switching threads here, so we must capture by value, [=] or [foo,bar].
1224:             (FLAGS_gpu_threading ? gParallelTests : gSerialTests).push(test);
1303:     SkTaskGroup::Enabler enabled(FLAGS_threads);
1365:     // At this point we're back in single-threaded land.
38: #include "SkThreadUtils.h"
185:     gRunning.push_back({id,SkGetThreadID()});
1074:             gDefinitelyThreadSafeWork.add([task,name,bitmap,data]{
1358:     gDefinitelyThreadSafeWork.wait();
skia.googlesource.com/skia:dm/DM.cpp: [ master, ] c++ Duplicate result
chromium.googlesource.com/skia:dm/DM.cpp: [ master, ] c++ Duplicate result
github.com/googlegsa/sharepoint.v3:projects/ApacheHttpClient/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java: [ master, ] java
1046:         public Thread thread;
93:     private static ReferenceQueueThread REFERENCE_QUEUE_THREAD;
917:         public synchronized void notifyWaitingThread(HostConfiguration configuration) {
928:         public synchronized void notifyWaitingThread(HostConnectionPool hostPool) {
1044:     private static class WaitingThread {
1061:     private static class ReferenceQueueThread extends Thread {
1068:         public ReferenceQueueThread() {
65: public class MultiThreadedHttpConnectionManager implements HttpConnectionManager {
256:     public MultiThreadedHttpConnectionManager() {
706:         private LinkedList waitingThreads = new LinkedList();
1034:         public LinkedList waitingThreads = new LinkedList();
91:      * The thread responsible for handling lost connections.
134:             if (REFERENCE_QUEUE_THREAD != null) {
135:                 REFERENCE_QUEUE_THREAD.shutdown();
136:                 REFERENCE_QUEUE_THREAD = null;
171:             // start the reference queue thread if needed
172:             if (REFERENCE_QUEUE_THREAD == null) {
173:                 REFERENCE_QUEUE_THREAD = new ReferenceQueueThread();
174:                 REFERENCE_QUEUE_THREAD.start();
507:                             waitingThread.thread = Thread.currentThread();
531:                             // interrupted by an external thread.  Regardless we need to 
624:      * If another thread is blocked in getConnection() that could use this
741:                 waiter.thread.interrupt();
912:          * Notifies a waiting thread that a connection for the given configuration is 
922:          * Notifies a waiting thread that a connection for the given configuration is 
923:          * available.  This will wake a thread waiting in this host pool or if there is not
924:          * one a thread in the connection pool will be notified.
930:             // find the thread we are going to notify, we want to ensure that each
931:             // waiting thread is only interrupted once so we will remove it from 
937:                     LOG.debug("Notifying thread waiting on host pool, hostConfig=" 
944:                     LOG.debug("No-one waiting on host pool, notifying next waiting thread.");
954:                 waitingThread.thread.interrupt();
1041:      * A simple struct-like class to combine the waiting thread and the connection 
1045:         /** The thread that is waiting for a connection */
1048:         /** The connection pool the thread is waiting for */
1051:         /** Flag to indicate if the thread was interrupted by the ConnectionPool. Set
1053:          * before the thread is interrupted. */
1058:      * A thread for listening for HttpConnections reclaimed by the garbage
1066:          * Create an instance and make this a daemon thread.
105:      * MultiThreadedHttpConnectionManager. All static resources are released, all threads are 
453:             WaitingThread waitingThread = null;
492:                     // threads, so they avoid being sacrificed before necessary
504:                         if (waitingThread == null) {
505:                             waitingThread = new WaitingThread();
506:                             waitingThread.hostConnectionPool = hostPool;
509:                             waitingThread.interruptedByConnectionPool = false;
516:                         hostPool.waitingThreads.addLast(waitingThread);
517:                         connectionPool.waitingThreads.addLast(waitingThread);
520:                         if (!waitingThread.interruptedByConnectionPool) {
529:                         if (!waitingThread.interruptedByConnectionPool) {
533:                             hostPool.waitingThreads.remove(waitingThread);
534:                             connectionPool.waitingThreads.remove(waitingThread);
735:             // interrupt all waiting threads
738:                 WaitingThread waiter = (WaitingThread) iter.next();
777:          * connection counts and notifies waiting threads, if appropriate.
787:             notifyWaitingThread(config);
915:          * @see #notifyWaitingThread(HostConnectionPool)
918:             notifyWaitingThread(getHostPool(configuration));
933:             WaitingThread waitingThread = null;
940:                 waitingThread = (WaitingThread) hostPool.waitingThreads.removeFirst();
941:                 waitingThreads.remove(waitingThread);
946:                 waitingThread = (WaitingThread) waitingThreads.removeFirst();
947:                 waitingThread.hostConnectionPool.waitingThreads.remove(waitingThread);
949:                 LOG.debug("Notifying no-one, there are no waiting threads");
952:             if (waitingThread != null) {
953:                 waitingThread.interruptedByConnectionPool = true;
1004:                 notifyWaitingThread(hostPool);
1052:          * to true inside {@link ConnectionPool#notifyWaitingThread(HostConnectionPool)} 
1115:                     LOG.debug("ReferenceQueueThread interrupted", e);
2:  * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java,v 1.47 2004/12/21 11:27:55 olegk Exp $
70:     private static final Log LOG = LogFactory.getLog(MultiThreadedHttpConnectionManager.class);
107:      * MultiThreadedHttpConnectionManager.
118:                 MultiThreadedHttpConnectionManager[]
119:                     connManagers = (MultiThreadedHttpConnectionManager[])
121:                         new MultiThreadedHttpConnectionManager
522:                             throw new IllegalThreadStateException(
523:                                 "Interrupted while waiting in MultiThreadedHttpConnectionManager");
705:         /** The list of WaitingThreads waiting for a connection */
736:             iter = waitingThreads.iterator();
764:             connection.getParams().setDefaults(MultiThreadedHttpConnectionManager.this.params);
765:             connection.setHttpConnectionManager(MultiThreadedHttpConnectionManager.this);
935:             if (hostPool.waitingThreads.size() > 0) {
942:             } else if (waitingThreads.size() > 0) {
1033:         /** The list of WaitingThreads for this host */
1070:             setName("MultiThreadedHttpConnectionManager cleanup");
android.googlesource.com/platform/superproject:external/vulkan-validation-layers/layers/threading.h: [ master, ] c++
44:     loader_platform_thread_id thread;
22: #define THREADING_H
37: enum THREADING_CHECKER_ERROR {
38:     THREADING_CHECKER_NONE,                 // Used for INFO & other non-error messages
39:     THREADING_CHECKER_MULTIPLE_THREADS,     // Object used simultaneously by multiple threads
40:     THREADING_CHECKER_SINGLE_THREAD_REUSE,  // Object used simultaneously by recursion in single thread
51: namespace threading {
55: inline bool startMultiThread() {
68: inline void finishMultiThread() { vulkan_in_use = false; }
53: volatile bool vulkan_multi_threaded = false;
84:         loader_platform_thread_id tid = loader_platform_get_thread_id();
87:             // There is no current use of the object.  Record writer thread.
91:             use_data->thread = tid;
96:                 if (use_data->thread != tid) {
99:                                         "THREADING ERROR : object of type %s is simultaneously used in thread %ld and thread %ld",
100:                                         typeName, use_data->thread, tid);
102:                         // Wait for thread-safe access to object instead of skipping call.
106:                         // There is now no current use of the object.  Record writer thread.
108:                         new_use_data->thread = tid;
113:                         use_data->thread = tid;
123:                 if (use_data->thread != tid) {
126:                                         "THREADING ERROR : object of type %s is simultaneously used in thread %ld and thread %ld",
127:                                         typeName, use_data->thread, tid);
129:                         // Wait for thread-safe access to object instead of skipping call.
133:                         // There is now no current use of the object.  Record writer thread.
135:                         new_use_data->thread = tid;
140:                         use_data->thread = tid;
172:         loader_platform_thread_id tid = loader_platform_get_thread_id();
179:             use_data->thread = tid;
180:         } else if (uses[object].writer_count > 0 && uses[object].thread != tid) {
184:                                 "THREADING ERROR : object of type %s is simultaneously used in thread %ld and thread %ld", typeName,
185:                                 uses[object].thread, tid);
187:                 // Wait for thread-safe access to object instead of skipping call.
195:                 use_data->thread = tid;
21: #ifndef THREADING_H
54: // starting check if an application is using vulkan from multiple threads.
56:     if (vulkan_multi_threaded) {
60:         vulkan_multi_threaded = true;
67: // finishing check if an application is using vulkan from multiple threads.
69: }  // namespace threading
98:                                         THREADING_CHECKER_MULTIPLE_THREADS, "THREADING",
125:                                         THREADING_CHECKER_MULTIPLE_THREADS, "THREADING",
162:         // Notify any waiting threads that this object may be safe to use
183:                                 THREADING_CHECKER_MULTIPLE_THREADS, "THREADING",
213:         // Notify any waiting threads that this object may be safe to use
406: #endif  // THREADING_H
github.com/google/perf_data_converter:quipper/compat/non_cros/detail/thread.h: [ master, ] c++
13: class Thread : public quipper::compat::ThreadInterface {
15:   explicit Thread(const string& name_prefix) {}
27:   std::thread thread_;
6: #define CHROMIUMOS_WIDE_PROFILING_COMPAT_EXT_DETAIL_THREAD_H_
5: #ifndef CHROMIUMOS_WIDE_PROFILING_COMPAT_EXT_DETAIL_THREAD_H_
10: #include <thread>
17:   void Start() override { thread_ = std::thread(&Thread::Run, this); }
19:   void Join() override { thread_.join(); }
21:   pid_t tid() override { return thread_.native_handle(); }
52: #endif  // CHROMIUMOS_WIDE_PROFILING_COMPAT_EXT_DETAIL_THREAD_H_
github.com/google/perf_data_converter:quipper/compat/cros/detail/thread.h: [ master, ] c++
13: class Thread : public quipper::compat::ThreadInterface,
16:   explicit Thread(const string& name_prefix) : thread_(this, name_prefix) {}
34:   base::DelegateSimpleThread thread_;
6: #define CHROMIUMOS_WIDE_PROFILING_COMPAT_CROS_DETAIL_THREAD_H_
5: #ifndef CHROMIUMOS_WIDE_PROFILING_COMPAT_CROS_DETAIL_THREAD_H_
9: #include "base/threading/simple_thread.h"
19:     thread_.Start();
23:     thread_.Join();
27:     return thread_.tid();
61: #endif  // CHROMIUMOS_WIDE_PROFILING_COMPAT_CROS_DETAIL_THREAD_H_
14:                public base::DelegateSimpleThread::Delegate {
github.com/fuchsia-mirror/third_party-skia:dm/DM.cpp: [ master, ] c++
124:     SkThreadID thread;
1265: SkThread* start_status_thread() {
1039: static SkTaskGroup gDefinitelyThreadSafeWork;
181:         if (task.thread == thisThread) {
1020: static bool match(const char* needle, const char* haystack) {
1021:     return 0 == strcmp("_", needle) || nullptr != strstr(haystack, needle);
1038: // .png encoding are definitely thread safe.  This lets us offload that work to CPU threads.
1266:     auto thread = new SkThread([] (void*) {
1276:     thread->start();
1277:     return thread;
1335:     std::unique_ptr<SkThread> statusThread(start_status_thread());
1362:     // With the parallel work running, run serial tasks and tests here on main thread.
62: DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?");
179:     SkThreadID thisThread = SkGetThreadID();
855:                                sk_ref_sp(gpuConfig->getColorSpace()), FLAGS_gpu_threading);
1037: // Even when a Task Sink reports to be non-threadsafe (e.g. GPU), we know things like
1080:             // We're likely switching threads here, so we must capture by value, [=] or [foo,bar].
1234:             (FLAGS_gpu_threading ? gParallelTests : gSerialTests).push(test);
1312:     SkTaskGroup::Enabler enabled(FLAGS_threads);
1375:     // At this point we're back in single-threaded land.
33: #include "SkThreadUtils.h"
161:     gRunning.push_back({id,SkGetThreadID()});
1082:             gDefinitelyThreadSafeWork.add([task,name,bitmap,data]{
1368:     gDefinitelyThreadSafeWork.wait();
gerrit.googlesource.com/prolog-cafe:src/repl/BlockingPrologControl.java: [ master, ] java
108:   private volatile Thread thread;
9:  * Prolog thread.<br>
68:  *      Thread.sleep(10);
89:  *          Thread.sleep(100);
107:   /** A volatile instance variable holding a thread. */
128:    * allocates a new <code>Thread</code> object, and start the execution of the given goal.
129:    * And then it stops the thread and returns <code>true</code>
144:    * allocates a new <code>Thread</code> object, and start the execution of the given goal.
145:    * And then it stops the thread and returns <code>true</code>
151:   thread = new Thread(this);
152:   thread.setName("Prolog-" + p.toString());
153:   thread.start(); // execute run() in new thread.
155:       wait();     // wait caller's thread.
166:    * initilizes the Prolog engine, allocates a new <code>Thread</code> object,
201:    * Finally, while the <code>thread</code> is not <code>null</code> and
203:    * it waits until another thread invokes the <code>notify()</code> method
207:    * @see #thread
214:   while (thread != null && resultReady) {
229:    * Finally, while the <code>thread</code> is not <code>null</code> and
231:    * it waits until another thread invokes the <code>notify()</code> method
235:    * @see #thread
242:   while (thread != null && resultReady) {
252:     return thread == null;
255:   /** Waits for this thread to die. */
257:   while (thread != null && ! resultReady) {
266:    * Forces the thread to stop.<br>
268:    * This method first sets the <code>resultReady</code> and <code>thread</code>
272:    * @see #thread
276:   thread = null;
281:    * Forces the thread to start the execution.<br>
284:    * allocates a new <code>Thread</code> object, and start the execution.
285:    * The Java Virtual Machine calls the <code>run</code> method of this thread.
290:   thread = new Thread(this);
291:   thread.start();
295:    * Forces the thread to continue the execution.<br>
340:    * This method first waits until another thread invokes the <code>notify()</code>
342:    * while the <code>thread</code> is not <code>null</code> and
348:    * @see #thread
351:   while (thread != null && ! resultReady) {
183:    * and wakes up all threads that are waiting on this object's monitor.
200:    * And then it wakes up all threads that are waiting by <code>notifyAll()</code>.
228:    * And then it wakes up all threads that are waiting by <code>notifyAll()</code>.
270:    * And then it wakes up all threads that are waiting by <code>notifyAll()</code>.
298:    * and then wakes up all threads that are waiting by <code>notifyAll()</code>.
github.com/GoogleCloudPlatform/google-cloud-visualstudio:GoogleCloudExtension/ProjectTemplates/ProjectTemplate.Tests/VisualStudioWrapper.cs: [ master, ] c#
24: using Thread = System.Threading.Thread;
186:                 Thread.Sleep(200);
github.com/google/mtail:vm/vm.go: [ master, ] go
27: type thread struct {
37: // expressions), mutable state (metrics), and a stack for the current thread of
49: 	t *thread // Current thread of execution
61: func (t *thread) Push(value interface{}) {
66: func (t *thread) Pop() (value interface{}) {
80: 	glog.Infof("Thread:")
90: func (t *thread) PopInt() (int64, error) {
111: func (t *thread) PopFloat() (float64, error) {
277: // i in thread t.
278: func (v *VM) execute(t *thread, i instr) {
281: 			v.errorf("panic in thread %#v at instr %q: %s", t, i, r)
613: 	t := new(thread)
android.googlesource.com/platform/external/devlib:src/netstats/src/com/arm/devlib/trafficcatcher/TrafficMetricsService.java: [ master, ] java
97:     private Thread thread;
5: import java.lang.Thread;
41:                 Thread.sleep(this.period);
43:                 if (Thread.interrupted()) {
117:         if (this.thread != null) {
121:         this.thread = new Thread(new TrafficPoller(runTag, getPackageManager(), pollingPeriod, packages));
122:         this.thread.start();
chromium.googlesource.com/infra/third_party/coverage:tests/test_concurrency.py: [ master, ] python
82:         THREAD = """\
165:     def test_threads(self):
168:     def test_threads_simple_code(self):
46:         class Producer(threading.Thread):
48:                 threading.Thread.__init__(self)
56:         class Consumer(threading.Thread):
58:                 threading.Thread.__init__(self)
87:         THREAD = """\
101:         monkey.patch_thread()
138:         elif C_TRACER or concurrency == "thread":
166:         self.try_some_code(self.THREAD, "thread", threading)
169:         self.try_some_code(self.SIMPLE, "thread", threading)
3: import os, os.path, sys, threading
80:     # Import the things to use threads.
83:         import threading
88:         import threading
94:         import eventlet.green.threading as threading
102:         import threading
140:             # can support all the concurrency, or if we are using threads.
161:                 "only threads are supported\n" % concurrency
github.com/apache/uima-ruta:ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/extension/TextRulerLearnerController.java: [ trunk, ] java
53:   protected Thread thread; // the thread in which we run the algorithm, null if not running
138:   public boolean runInNewThread(final String inputFolderPath, final String additionalFolderPath,
32:  * and the id, cares about running the algorithm in an own thread, act as the algorithm's delegate,
102:     return thread != null;
130:     thread = null;
142:     if (thread == null) {
145:       thread = new Thread(new Runnable() {
158:       thread.setPriority(Thread.NORM_PRIORITY);
159:       thread.start();
github.com/google/gtm-oauth2:Source/GTMOAuth2Authentication.m: [ master, ] objectivec
104: @property (atomic, retain) NSThread *thread;
96:   NSThread *thread_;
111:                                          thread:(NSThread *)thread;
120:             thread = thread_,
127:                                          thread:(NSThread *)thread {
134:   obj.thread = thread;
142:   [thread_ release];
356:                                               thread:[NSThread currentThread]];
380:                                               thread:[NSThread currentThread]];
572:   // Invoke any callbacks on the proper thread
574:     NSThread *targetThread = args.thread;
580:       // (or if it's nil, we'll use the main thread) for callbacks.
597:         // if that's available, else we'll hope the original thread has a spinning run loop.
656:                                               thread:[NSThread currentThread]];
575:     BOOL isSameThread = [targetThread isEqual:[NSThread currentThread]];
576:     if (isSameThread) {
608:                        onThread:targetThread
github.com/apache/jackrabbit-filevault:vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTask.java: [ trunk, ] java
78:     private Thread thread;
112:         // wait for thread
116:             while (thread != null && thread.isAlive() && cnt-- > 0) {
120:                     thread.join(10000);
122:                     log.error("Error while waiting for thread: " + thread.getName(), e);
124:                 if (thread.isAlive()) {
125:                     // try to interrupt the thread
126:                     thread.interrupt();
130:             thread = null;
157:         ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
158:         Thread.currentThread().setContextClassLoader(dynLoader);
162:             Thread.currentThread().setContextClassLoader(oldLoader);
165:         thread  = new Thread(this, "Vault RCP Task - " + id);
166:         thread.setContextClassLoader(dynLoader);
167:         thread.start();
github.com/google/arithmancer:third_party/werkzeug/serving.py: [ master, ] python
50:     import _thread as thread
401:     multithread = False
453: class ThreadedWSGIServer(ThreadingMixIn, BaseWSGIServer):
455:     multithread = True
48:     import thread
508:     """When this function is run from the main thread, it will force other
585:     but running the reloader thread.
611:         thread.start_new_thread(main_func, ())
661:                      thread?
53:     from SocketServer import ThreadingMixIn, ForkingMixIn
56:     from socketserver import ThreadingMixIn, ForkingMixIn
88:             'wsgi.multithread':     self.server.multithread,
400:     """Simple single-threaded, single-process WSGI server."""
454:     """A WSGI server that does threading."""
469: def make_server(host, port, app=None, threaded=False, processes=1,
472:     """Create a new server instance that is either threaded, or forks
475:     if threaded and processes > 1:
478:     elif threaded:
479:         return ThreadedWSGIServer(host, port, app, request_handler,
509:     threads to exit when any modules currently loaded change.
624:                extra_files=None, reloader_interval=1, threaded=False,
660:     :param threaded: should the process handle each request in a separate
690:         make_server(hostname, port, application, threaded,
476:         raise ValueError("cannot have a multithreaded and "
628:     wraps `wsgiref` to fix the wrong default reporting of the multithreaded
629:     WSGI variable and adds optional multithreading and fork support.
github.com/google/kythe:third_party/leveldb/db/db_bench.cc: [ master, ] c++
535:     ThreadState* thread;
288: struct ThreadState {
294:   ThreadState(int index)
532:   struct ThreadArg {
539:   static void ThreadBody(void* v) {
70: static int FLAGS_threads = 1;
196:     // Just keep the messages from one thread
246:       // Rate is computed on actual elapsed time, not the sum of per-thread
274:   // Each thread goes through the following states:
287: // Per-thread state for concurrent executions of the same benchmark.
488:         num_threads++;  // Add extra thread for writing
542:     ThreadState* thread = arg->thread;
554:     thread->stats.Start();
555:     (arg->bm->*(arg->method))(thread);
556:     thread->stats.Stop();
580:       arg[i].thread = new ThreadState(i);
581:       arg[i].thread->shared = &shared;
598:       arg[0].thread->stats.Merge(arg[i].thread->stats);
600:     arg[0].thread->stats.Report(name);
603:       delete arg[i].thread;
608:   void Crc32c(ThreadState* thread) {
617:       thread->stats.FinishedSingleOp();
623:     thread->stats.AddBytes(bytes);
624:     thread->stats.AddMessage(label);
627:   void AcquireLoad(ThreadState* thread) {
632:     thread->stats.AddMessage("(each op is 1000 loads)");
638:       thread->stats.FinishedSingleOp();
643:   void SnappyCompress(ThreadState* thread) {
654:       thread->stats.FinishedSingleOp();
658:       thread->stats.AddMessage("(snappy failure)");
663:       thread->stats.AddMessage(buf);
664:       thread->stats.AddBytes(bytes);
668:   void SnappyUncompress(ThreadState* thread) {
679:       thread->stats.FinishedSingleOp();
684:       thread->stats.AddMessage("(snappy failure)");
686:       thread->stats.AddBytes(bytes);
705:   void WriteSeq(ThreadState* thread) {
706:     DoWrite(thread, true);
709:   void WriteRandom(ThreadState* thread) {
710:     DoWrite(thread, false);
713:   void DoWrite(ThreadState* thread, bool seq) {
717:       thread->stats.AddMessage(msg);
727:         const int k = seq ? i+j : (thread->rand.Next() % FLAGS_num);
732:         thread->stats.FinishedSingleOp();
740:     thread->stats.AddBytes(bytes);
743:   void ReadSequential(ThreadState* thread) {
749:       thread->stats.FinishedSingleOp();
753:     thread->stats.AddBytes(bytes);
756:   void ReadReverse(ThreadState* thread) {
762:       thread->stats.FinishedSingleOp();
766:     thread->stats.AddBytes(bytes);
769:   void ReadRandom(ThreadState* thread) {
775:       const int k = thread->rand.Next() % FLAGS_num;
780:       thread->stats.FinishedSingleOp();
784:     thread->stats.AddMessage(msg);
787:   void ReadMissing(ThreadState* thread) {
792:       const int k = thread->rand.Next() % FLAGS_num;
795:       thread->stats.FinishedSingleOp();
799:   void ReadHot(ThreadState* thread) {
805:       const int k = thread->rand.Next() % range;
808:       thread->stats.FinishedSingleOp();
812:   void SeekRandom(ThreadState* thread) {
819:       const int k = thread->rand.Next() % FLAGS_num;
824:       thread->stats.FinishedSingleOp();
828:     thread->stats.AddMessage(msg);
831:   void DoDelete(ThreadState* thread, bool seq) {
838:         const int k = seq ? i+j : (thread->rand.Next() % FLAGS_num);
842:         thread->stats.FinishedSingleOp();
852:   void DeleteSeq(ThreadState* thread) {
853:     DoDelete(thread, true);
856:   void DeleteRandom(ThreadState* thread) {
857:     DoDelete(thread, false);
860:   void ReadWhileWriting(ThreadState* thread) {
861:     if (thread->tid > 0) {
862:       ReadRandom(thread);
864:       // Special thread that keeps writing until other threads are done.
868:           MutexLock l(&thread->shared->mu);
869:           if (thread->shared->num_done + 1 >= thread->shared->num_initialized) {
875:         const int k = thread->rand.Next() % FLAGS_num;
886:       thread->stats.Start();
890:   void Compact(ThreadState* thread) {
69: // Number of concurrent threads to run.
289:   int tid;             // 0..n-1 when running in n threads
290:   Random rand;         // Has different seeds for different threads
441:       void (Benchmark::*method)(ThreadState*) = NULL;
443:       int num_threads = FLAGS_threads;
526:         RunBenchmark(num_threads, name, method);
536:     void (Benchmark::*method)(ThreadState*);
540:     ThreadArg* arg = reinterpret_cast<ThreadArg*>(v);
568:                     void (Benchmark::*method)(ThreadState*)) {
575:     ThreadArg* arg = new ThreadArg[n];
582:       Env::Default()->StartThread(ThreadBody, &arg[i]);
870:             // Other threads have finished
949:     } else if (sscanf(argv[i], "--threads=%d%c", &n, &junk) == 1) {
950:       FLAGS_threads = n;
github.com/googlearchive/appengine-try-python-flask:lib/werkzeug/serving.py: [ master, ] python Duplicate result
github.com/apache/commons-jci:fam/src/main/java/org/apache/commons/jci2/monitor/FilesystemAlterationMonitor.java: [ trunk, ] java
43:     private Thread thread = null;
29:  * It's a runnable that spawns of a monitoring thread triggering the
42:     private volatile long delay = 3000; // volatile because shared with daemon thread
52:         thread = new Thread(this);
53:         thread.setName("Filesystem Alteration Monitor");
54:         thread.setDaemon(true);
55:         thread.start();
62:         if (thread != null) {
64:                 thread.join(delay);
129:                 Thread.sleep(delay);
github.com/src-d/kmcuda:src/test.R: [ develop, ] r
96:     needle <- "--file="
97:     match <- grep(needle, cmdArgs)
99:       return(normalizePath(sub(needle, "", cmdArgs[match])))
github.com/GoogleCloudPlatform/deepbreath:third_party/gmail.js: [ master, ] javascript
2597:   api.dom.thread = function(element) {
155:   api.check.is_thread = function() {
1195:       'view_thread': {
732:                       'toggle_threads'  : 'toggle_threads'
704:                       'dm'          : 'delete_message_in_thread',
730:                       'rtr'         : 'restore_message_in_thread',
1190:     api.tracker.supported_observers = ['view_thread', 'view_email', 'load_email_menu', 'recipient_change', 'compose'];
1193:       // when a thread is clicked on in a mailbox for viewing - note: this should fire at a similar time (directly after) as the open_email XHR observer
1199:           match = new api.dom.thread(match);
1202:           // look for any email elements in this thread that are currently displaying
1206:             api.observe.trigger_dom('view_email', email, api.tracker.dom_observers.view_thread.sub_observers.view_email.handler);
1211:           // when an individual email is loaded within a thread (also fires when thread loads displaying the latest email)
1804:         data.thread_id = x[1];
2434:     An object for interacting with an email currently present in the DOM. Represents an individual email message within a thread
2550:         // retrieve & cache the data for this whole thread of emails
2593:     An object for interacting with an email currently present in the DOM. Represents a conversation thread
2595:     Expects a jQuery DOM element for the thread wrapper div (div.if as returned by the 'view_thread' observer)
2598:     if (!element || (!element.hasClass('if'))) api.tools.error('api.dom.thread called with invalid element/id');
2603:   $.extend(api.dom.thread.prototype, {
337:       return Object.keys(data.threads);
817:       if(api.observe.bound('toggle_threads')) {
818:         triggered.toggle_threads = response;
825:         if(api.observe.bound('toggle_threads')) {
826:           triggered.toggle_threads = response;
1799:     var threads = {};
1808:         data.total_threads = x[8];
1814:         if(data.threads == undefined) {
1815:           data.threads = {};
1818:         data.threads[x[1]] = {};
1819:         data.threads[x[1]].is_deleted = x[13] == undefined;
1820:         data.threads[x[1]].reply_to_id = x[2];
1821:         data.threads[x[1]].from = x[5];
1822:         data.threads[x[1]].from_email = x[6];
1823:         data.threads[x[1]].timestamp = x[7];
1824:         data.threads[x[1]].datetime = x[24];
1825:         data.threads[x[1]].attachments = x[21].split(',');
1826:         data.threads[x[1]].subject = x[12];
1827:         data.threads[x[1]].content_html = (x[13] != undefined) ? x[13][6] : x[8];
1828:         data.threads[x[1]].to = (x[13] != undefined) ? x[13][1] : ((x[37] != undefined) ? x[37][1]:[]);
1829:         data.threads[x[1]].cc = (x[13] != undefined) ? x[13][2] : [];
1830:         data.threads[x[1]].bcc = (x[13] != undefined) ? x[13][3] : [];
1831:         data.threads[x[1]].reply_to = api.tools.get_reply_to(x[13]);
1834:           data.threads[x[1]].content_plain = (x[13] != undefined) ? $(x[13][6]).text() : x[8];
1837:           data.threads[x[1]].content_plain = (x[13] != undefined) ? x[13][6] : x[8];
1958:       var threads = displayed_email_data.threads;
1959:       var total_threads = displayed_email_data.total_threads;
1964:       for (var id in threads) {
1965:         var email = threads[id];
1969:           delete threads[id];
1970:           total_threads.splice(total_threads.indexOf(id), 1);
1977:       for (id in email_data.threads) {
1982:           var email = email_data.threads[id];
1988:           displayed_email_data.threads = {};
1989:           displayed_email_data.threads[id] = email;
1991:           displayed_email_data.total_threads = [id];
2552:         $.each(data.threads, function(email_id, email_data) {
github.com/GoogleChrome/chrome-app-samples:samples/text-editor/lib/ace/mode/text.js: [ master, ] javascript
135:             needle: needle
117:         var needle = line.substring(Math.max(startOuter, 0),
121:         if ((startOuter >= 0 && /^[\w\d]/.test(needle)) ||
122:             (endOuter <= lineCols && /[\w\d]$/.test(needle)))
125:         needle = line.substring(selection.start.column, selection.end.column);
126:         if (!/^[\w\d]+$/.test(needle))
chromium.googlesource.com/chromium/deps/psyco_win32:psyco/profiler.py: [ master, ] python
20:     import dummy_thread as thread
365: def psyco_start_new_thread(callable, args, kw=None):
371: original_start_new_thread = thread.start_new_thread
358: def psyco_thread_stub(callable, args, kw):
18:     import thread
32: # a lock for a thread-safe go()
33: go_lock = thread.allocate_lock()
260:         self.lock = thread.allocate_lock()
343: # and thread.start_new_thread().
366:     "This is the Psyco-aware version of thread.start_new_thread()."
367:     return original_start_new_thread(psyco_thread_stub, (callable, args, kw))
374: thread.start_new_thread = psyco_start_new_thread
375: # hack to patch threading._start_new_thread if the module is
378:     hasattr(sys.modules['threading'], '_start_new_thread')):
379:     sys.modules['threading']._start_new_thread = psyco_start_new_thread
204:             alarm.stop(1)   # wait for parallel threads to stop
377: if ('threading' in sys.modules and
chromium.googlesource.com/infra/infra/codesearch:go/src/go.chromium.org/luci/common/runtime/tracer/tracer.go: [ master, ] go
36: 	Thread  Scope = "t"
383: 	threadName metadataType = "thread_name"
386: 	threadSortIndex metadataType = "thread_sort_index"
316: 	// on a given thread. These can be nested in the same Tid but must not be
325: 	// Instant Events. Thread/process/global instantaneous event. The instant
336: 	// of relying on Tid. They can overload within the same thread.
384: 	// Sets the thread sort order position. The sort index is provided in a
395: 	Tid       int          `json:"tid"`            // Required. Thread ID. It is implicitly used to set start/end.
430: // context embeds a pseudo thread id for this context. It's useful to keep
490: // current pseudo process id or pseudo thread id.
335: 	// Async Events. Events that flows multiple threads, referenced by ID instead
402: 	Scope     Scope        `json:"s,omitempty"`    // Optional. Only for Instant. Defaults to ScopeThread.
409: 	ThreadTimestamp microseconds `json:"tts,omitempty"`    // Undocumented.
410: 	ThreadDuration  microseconds `json:"tdur,omitempty"`   // Undocumented.
github.com/apache/commons-dbcp:src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java: [ master, ] java
875:         private final Thread thread;
585:     class TestThread implements Runnable {
592:         public TestThread() {
595:         public TestThread(final int iter) {
599:         public TestThread(final int iter, final int delay) {
969:         public Thread getThread() {
715:     private static final boolean DISPLAY_THREAD_DETAILS=
564:     public void testThreaded() {
735:     protected void multipleThreads(final int holdTime,
757:     protected void multipleThreads(final int holdTime,
859:     private static int currentThreadCount = 0;
568:             final Thread t = new Thread(threads[i]);
574:                     Thread.sleep(100L);
580:                 fail("Thread failed: " + i);
616:                     Thread.sleep(_random.nextInt(_delay));
625:                         Thread.sleep(_random.nextInt(_delay));
716:         Boolean.valueOf(System.getProperty("TestConnectionPool.display.thread.details", "false")).booleanValue();
718:     // mvn test -DargLine="-DTestConnectionPool.display.thread.details=true"
728:      * @param holdTime time in ms that a thread holds a connection before returning it to the pool
748:      * @param holdTime time in ms that a thread holds a connection before returning it to the pool
765:                     public void uncaughtException(final Thread t, final Throwable e) {
781:                 Thread.sleep(duration);
798:                     poolTest.thread.join();
828:                     if (DISPLAY_THREAD_DETAILS || (pts.length/2 != failed)){
873:         private String state; // No need to be volatile if it is read after the thread finishes
883:         private long started; // when thread started
884:         private long ended; // when thread ended
886:         private long connected; // when thread last connected
887:         private long postconnected; // when thread released connection
907:             isRun = true; // Must be done here so main thread is guaranteed to be able to set it false
909:             thread =
910:                 new Thread(threadGroup, this, "Thread+" + currentThreadCount++);
911:             thread.setDaemon(false);
917:             thread.start();
941:                     Thread.sleep(connHoldTime);
970:             return thread;
565:         final TestThread[] threads = new TestThread[getMaxTotal()];
566:         for(int i=0;i<threads.length;i++) {
567:             threads[i] = new TestThread(50,50);
571:         for(int i=0;i<threads.length;i++) {
572:             while(!(threads[i]).complete()) {
579:             if(threads[i] != null && threads[i].failed()) {
722:      * Launches a group of 2 * getMaxTotal() threads, each of which will attempt to obtain a connection
724:      * threads will continue this process indefinitely.  If {@code expectError} is true, exactly 1/2 of the
725:      * threads are expected to either throw exceptions or fail to complete. If {@code expectError} is false,
726:      * all threads are expected to complete successfully.
730:      * @param loopOnce whether threads should complete the borrow - hold - return cycle only once, or loop indefinitely
742:      * Launches a group of {@code numThreads} threads, each of which will attempt to obtain a connection
744:      * threads will continue this process indefinitely.  If {@code expectError} is true, exactly 1/2 of the
745:      * threads are expected to either throw exceptions or fail to complete. If {@code expectError} is false,
746:      * all threads are expected to complete successfully.  Threads are stopped after {@code duration} ms.
750:      * @param loopOnce whether threads should complete the borrow - hold - return cycle only once, or loop indefinitely
752:      * @param numThreads the number of threads
762:                 // Catch Exception so we can stop all threads if one fails
763:                 final ThreadGroup threadGroup = new ThreadGroup("foo") {
771:                 // Create all the threads
773:                     pts[i] = new PoolTest(threadGroup, holdTime, expectError, loopOnce, numStatements);
775:                 // Start all the threads
780:                 // Give all threads a chance to start and succeed
783:                 // Stop threads
789:                  * Wait for all threads to terminate.
790:                  * This is essential to ensure that all threads have a chance to update success[0]
817:                 System.out.println("Multithread test time = " + time
818:                         + " ms. Threads: " + pts.length
849:                         System.out.println("NOTE: some threads did not run the code: "+didNotRun);
852:                     assertTrue("Expected some of the threads to fail",failed > 0);
853:                     // Assume that threads that did not run would have timed out.
854:                     assertEquals("WARNING: Expected half the threads to fail",pts.length/2,failed+didNotRun);
856:                     assertEquals("Did not expect any threads to fail",0,failed);
895:         public PoolTest(final ThreadGroup threadGroup, final int connHoldTime, final boolean isStopOnException) {
896:             this(threadGroup, connHoldTime, isStopOnException, false, 1);
899:         public PoolTest(final ThreadGroup threadGroup, final int connHoldTime, final boolean isStopOnException, final int numStatements) {
900:             this(threadGroup, connHoldTime, isStopOnException, false, numStatements);
903:         private PoolTest(final ThreadGroup threadGroup, final int connHoldTime, final boolean isStopOnException, final boolean once, final int numStatements) {
738:         multipleThreads(holdTime, expectError, loopOnce, maxWaitMillis, 1, 2 * getMaxTotal(), 300);
759:             final long maxWaitMillis, final int numStatements, final int numThreads, final long duration) throws Exception {
761:                 final PoolTest[] pts = new PoolTest[numThreads];
github.com/fuchsia-mirror/traceviz:src/traceviz.h: [ master, ] c++
116: struct Thread : public Object {
106:     virtual Thread* as_thread() { return nullptr; }
120:     virtual Thread* as_thread() { return this; }
90: #define KTHREAD  2 // extra = pid
160:     Thread* kthread_list;
94: struct Thread;
119:     Thread(uint32_t id);
170:     Thread* active[MAXCPU];
179:     void evt_thread_name(uint32_t tid, uint32_t pid, const char* name);
184:     void evt_process_create(uint64_t ts, Thread* t, uint32_t pid);
185:     void evt_process_delete(uint64_t ts, Thread* t, uint32_t pid);
186:     void evt_process_start(uint64_t ts, Thread* t, uint32_t pid, uint32_t tid);
187:     void evt_thread_create(uint64_t ts, Thread* t, uint32_t tid, uint32_t pid);
188:     void evt_thread_delete(uint64_t ts, Thread* t, uint32_t tid);
189:     void evt_thread_start(uint64_t ts, Thread* t, uint32_t tid);
190:     void evt_msgpipe_create(uint64_t ts, Thread* t, uint32_t id, uint32_t otherid);
191:     void evt_msgpipe_delete(uint64_t ts, Thread* t, uint32_t id);
192:     void evt_msgpipe_write(uint64_t ts, Thread* t, uint32_t id, uint32_t bytes, uint32_t handles);
193:     void evt_msgpipe_read(uint64_t ts, Thread* t, uint32_t id, uint32_t bytes, uint32_t handles);
194:     void evt_port_create(uint64_t ts, Thread* t, uint32_t id);
195:     void evt_port_wait(uint64_t ts, Thread* t, uint32_t id);
196:     void evt_port_wait_done(uint64_t ts, Thread* t, uint32_t id);
197:     void evt_port_delete(uint64_t ts, Thread* t, uint32_t id);
198:     void evt_wait_one(uint64_t ts, Thread* t, uint32_t id, uint32_t signals, uint64_t timeout);
199:     void evt_wait_one_done(uint64_t ts, Thread* t, uint32_t id, uint32_t pending, uint32_t status);
205:     void evt_probe(uint64_t ts, Thread* t, uint32_t evt, uint32_t arg0, uint32_t arg1);
212:     Thread* find_thread(uint32_t id, bool create = true);
215:     Thread* find_kthread(uint32_t id, bool create = true);
180:     void evt_kthread_name(uint32_t tid, const char* name);
183:                             uint32_t oldthread, uint32_t newthread);
github.com/apache/lucy-clownfish:runtime/core/Clownfish/TestHarness/TestUtils.c: [ master, ] c
191: struct Thread {
252: struct Thread {
201: S_thread(void *arg) {
262: S_thread(void *arg) {
253:     pthread_t         pthread;
214: TestUtils_thread_create(thread_routine_t routine, void *arg,
231: TestUtils_thread_yield() {
236: TestUtils_thread_join(Thread *thread) {
275: TestUtils_thread_create(thread_routine_t routine, void *arg,
292: TestUtils_thread_yield() {
297: TestUtils_thread_join(Thread *thread) {
311: TestUtils_thread_create(thread_routine_t routine, void *arg,
321: TestUtils_thread_yield() {
325: TestUtils_thread_join(Thread *thread) {
198: bool TestUtils_has_threads = true;
259: bool TestUtils_has_threads = true;
308: bool TestUtils_has_threads = false;
194:     thread_routine_t  routine;
202:     Thread *thread = (Thread*)arg;
204:     if (thread->runtime) {
205:         TestUtils_set_host_runtime(thread->runtime);
208:     thread->routine(thread->arg);
213: Thread*
216:     Thread *thread = (Thread*)MALLOCATE(sizeof(Thread));
217:     thread->runtime = host_runtime;
218:     thread->routine = routine;
219:     thread->arg     = arg;
221:     thread->handle = CreateThread(NULL, 0, S_thread, thread, 0, NULL);
222:     if (thread->handle == NULL) {
223:         FREEMEM(thread);
227:     return thread;
237:     DWORD event = WaitForSingleObject(thread->handle, INFINITE);
238:     FREEMEM(thread);
255:     thread_routine_t  routine;
263:     Thread *thread = (Thread*)arg;
265:     if (thread->runtime) {
266:         TestUtils_set_host_runtime(thread->runtime);
269:     thread->routine(thread->arg);
274: Thread*
277:     Thread *thread = (Thread*)MALLOCATE(sizeof(Thread));
278:     thread->runtime = host_runtime;
279:     thread->routine = routine;
280:     thread->arg     = arg;
282:     int err = pthread_create(&thread->pthread, NULL, S_thread, thread);
284:         FREEMEM(thread);
288:     return thread;
298:     int err = pthread_join(thread->pthread, NULL);
299:     FREEMEM(thread);
305: /**************************** No thread support ****************************/
310: Thread*
316:     THROW(ERR, "No thread support");
317:     UNREACHABLE_RETURN(Thread*);
326:     UNUSED_VAR(thread);
327:     THROW(ERR, "No thread support");
224:         THROW(ERR, "CreateThread failed: %s", Err_win_error());
232:     SwitchToThread();
246:       && defined(CHY_HAS_PTHREAD_H) \
249: #include <pthread.h>
285:         THROW(ERR, "pthread_create failed: %s", strerror(err));
301:         THROW(ERR, "pthread_create failed: %s", strerror(err));
187: #if !defined(CFISH_NOTHREADS) && defined(CHY_HAS_WINDOWS_H)
244: /******************************** pthreads *********************************/
245: #elif !defined(CFISH_NOTHREADS) \
chromium.googlesource.com/chromium/src/third_party/WebKit/Source/devtools:front_end/sdk/TracingModel.js: [ master, ] javascript
874: SDK.TracingModel.Thread = class extends SDK.TracingModel.NamedObject {
101:   static browserMainThread(tracingModel) {
299:   threadByName(processName, threadName) {
461:   ThreadSortIndex: 'thread_sort_index',
462:   ThreadName: 'thread_name'
833:   threadById(id) {
846:   threadByName(name) {
854:   _setThreadByName(name, thread) {
869:   sortedThreads() {
95:    * @return {?SDK.TracingModel.Thread}
120:       return tracingStartedInBrowser[0].thread;
121:     Common.console.error('Failed to find browser main thread in trace, some timeline features may be unavailable');
146:       for (const thread of process._threads.values())
147:         thread.tracingComplete();
163:       for (const thread of process._threads.values()) {
164:         for (const event of thread.events()) {
169:         for (const event of thread.asyncEvents()) {
217:     // chronological order. However, also add individual async events to the thread flow (above), so we can easily
297:    * @return {?SDK.TracingModel.Thread}
349:         event.thread._addAsyncEvent(asyncEvent);
385:       event.thread._addAsyncEvent(asyncEvent);
503:    * @param {!SDK.TracingModel.Thread} thread
505:   constructor(categories, name, phase, startTime, thread) {
509:     this._parsedCategories = thread._model._parsedCategoriesForString(categories);
516:     /** @type {!SDK.TracingModel.Thread} */
517:     this.thread = thread;
527:    * @param {!SDK.TracingModel.Thread} thread
530:   static fromPayload(payload, thread) {
532:         payload.cat, payload.name, /** @type {!SDK.TracingModel.Phase} */ (payload.ph), payload.ts / 1000, thread);
634:    * @param {!SDK.TracingModel.Thread} thread
636:   constructor(category, name, startTime, thread) {
637:     super(category, name, SDK.TracingModel.Phase.SnapshotObject, startTime, thread);
648:    * @param {!SDK.TracingModel.Thread} thread
651:   static fromPayload(payload, thread) {
652:     const snapshot = new SDK.TracingModel.ObjectSnapshot(payload.cat, payload.name, payload.ts / 1000, thread);
723:     super(startEvent.categoriesString, startEvent.name, startEvent.phase, startEvent.startTime, startEvent.thread);
817:     /** @type {!Map<number, !SDK.TracingModel.Thread>} */
831:    * @return {!SDK.TracingModel.Thread}
834:     let thread = this._threads.get(id);
835:     if (!thread) {
836:       thread = new SDK.TracingModel.Thread(this, id);
837:       this._threads.set(id, thread);
839:     return thread;
844:    * @return {?SDK.TracingModel.Thread}
852:    * @param {!SDK.TracingModel.Thread} thread
855:     this._threadByName.set(name, thread);
867:    * @return {!Array.<!SDK.TracingModel.Thread>}
116:       return browserProcesses[0].threadByName('CrBrowserMain');
202:     // We do allow records for unrelated threads to arrive out-of-order,
216:     // Build async event when we've got events from all threads & processes, so we can sort them and process in the
237:       case SDK.TracingModel.MetadataEvent.ThreadSortIndex:
238:         process.threadById(payload.tid)._setSortIndex(payload.args['sort_index']);
240:       case SDK.TracingModel.MetadataEvent.ThreadName:
241:         process.threadById(payload.tid)._setName(payload.args['name']);
296:    * @param {string} threadName
301:     return process && process.threadByName(threadName);
818:     this._threads = new Map();
819:     this._threadByName = new Map();
847:     return this._threadByName.get(name) || null;
863:     return this.threadById(payload.tid)._addEvent(payload);
870:     return SDK.TracingModel.NamedObject._sort(this._threads.valuesArray());
107:     const crRendererMainThreads = [];
111:       crRendererMainThreads.push(...process.sortedThreads().filter(t => t.name() === 'CrBrowserMain'));
113:     if (crRendererMainThreads.length === 1)
114:       return crRendererMainThreads[0];
951:     this._process._setThreadByName(name, this);
github.com/googlearchive/cloud-playground:lib/werkzeug/serving.py: [ master, ] python Duplicate result
github.com/apache/maven-wagon:wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ShellCommand.java: [ master, ] java
53:         private Thread thread;
github.com/GoogleChrome/chrome-app-samples:samples/text-editor/lib/ace/editor_highlight_selected_word_test.js: [ master, ] javascript
139:             needle: "Mauris"
194:             needle: "consectetur"

Took 191.067747ms for 9058KB index data, 431133 ngram matches, 99158 docs considered, 98021 docs (1415MB) loaded, 5897642 docs and 0 shards skipped